Coverage Report

Created: 2026-01-18 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/Zend/Optimizer/zend_inference.h
Line
Count
Source
1
/*
2
   +----------------------------------------------------------------------+
3
   | Zend Engine, e-SSA based Type & Range Inference                      |
4
   +----------------------------------------------------------------------+
5
   | Copyright (c) The PHP Group                                          |
6
   +----------------------------------------------------------------------+
7
   | This source file is subject to version 3.01 of the PHP license,      |
8
   | that is bundled with this package in the file LICENSE, and is        |
9
   | available through the world-wide-web at the following url:           |
10
   | https://www.php.net/license/3_01.txt                                 |
11
   | If you did not receive a copy of the PHP license and are unable to   |
12
   | obtain it through the world-wide-web, please send a note to          |
13
   | license@php.net so we can mail you a copy immediately.               |
14
   +----------------------------------------------------------------------+
15
   | Authors: Dmitry Stogov <dmitry@php.net>                              |
16
   +----------------------------------------------------------------------+
17
*/
18
19
#ifndef ZEND_INFERENCE_H
20
#define ZEND_INFERENCE_H
21
22
#include "zend_optimizer.h"
23
#include "zend_ssa.h"
24
#include "zend_bitset.h"
25
26
/* Bitmask for type inference (zend_ssa_var_info.type) */
27
#include "zend_type_info.h"
28
29
#include <stdint.h>
30
31
0
#define MAY_BE_PACKED_GUARD         (1<<27) /* needs packed array guard */
32
0
#define MAY_BE_CLASS_GUARD          (1<<27) /* needs class guard */
33
24.9k
#define MAY_BE_GUARD                (1<<28) /* needs type guard */
34
35
#define MAY_HAVE_DTOR \
36
88
  (MAY_BE_OBJECT|MAY_BE_RESOURCE \
37
88
  |MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE)
38
39
#define DEFINE_SSA_OP_HAS_RANGE(opN) \
40
  static zend_always_inline bool _ssa_##opN##_has_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
41
7.53k
  { \
42
7.53k
    if (opline->opN##_type == IS_CONST) { \
43
1.02k
      zval *zv = CRT_CONSTANT(opline->opN); \
44
1.02k
      return (Z_TYPE_P(zv) == IS_LONG); \
45
6.50k
    } else { \
46
6.50k
      return (opline->opN##_type != IS_UNUSED && \
47
6.50k
            ssa->var_info && \
48
6.50k
            ssa_op->opN##_use >= 0 && \
49
6.50k
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
6.50k
    } \
51
7.53k
    return 0; \
52
7.53k
  } \
Unexecuted instantiation: zend_jit.c:_ssa_op1_has_range
Unexecuted instantiation: zend_jit.c:_ssa_op2_has_range
Unexecuted instantiation: dce.c:_ssa_op1_has_range
Unexecuted instantiation: dce.c:_ssa_op2_has_range
Unexecuted instantiation: dfa_pass.c:_ssa_op1_has_range
Unexecuted instantiation: dfa_pass.c:_ssa_op2_has_range
Unexecuted instantiation: escape_analysis.c:_ssa_op1_has_range
Unexecuted instantiation: escape_analysis.c:_ssa_op2_has_range
Unexecuted instantiation: sccp.c:_ssa_op1_has_range
Unexecuted instantiation: sccp.c:_ssa_op2_has_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_has_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_has_range
Unexecuted instantiation: zend_dump.c:_ssa_op1_has_range
Unexecuted instantiation: zend_dump.c:_ssa_op2_has_range
Unexecuted instantiation: zend_func_info.c:_ssa_op1_has_range
Unexecuted instantiation: zend_func_info.c:_ssa_op2_has_range
zend_inference.c:_ssa_op1_has_range
Line
Count
Source
41
4.25k
  { \
42
4.25k
    if (opline->opN##_type == IS_CONST) { \
43
377
      zval *zv = CRT_CONSTANT(opline->opN); \
44
377
      return (Z_TYPE_P(zv) == IS_LONG); \
45
3.87k
    } else { \
46
3.87k
      return (opline->opN##_type != IS_UNUSED && \
47
3.87k
            ssa->var_info && \
48
3.87k
            ssa_op->opN##_use >= 0 && \
49
3.87k
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
3.87k
    } \
51
4.25k
    return 0; \
52
4.25k
  } \
zend_inference.c:_ssa_op2_has_range
Line
Count
Source
41
3.27k
  { \
42
3.27k
    if (opline->opN##_type == IS_CONST) { \
43
649
      zval *zv = CRT_CONSTANT(opline->opN); \
44
649
      return (Z_TYPE_P(zv) == IS_LONG); \
45
2.62k
    } else { \
46
2.62k
      return (opline->opN##_type != IS_UNUSED && \
47
2.62k
            ssa->var_info && \
48
2.62k
            ssa_op->opN##_use >= 0 && \
49
2.62k
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
2.62k
    } \
51
3.27k
    return 0; \
52
3.27k
  } \
Unexecuted instantiation: zend_optimizer.c:_ssa_op1_has_range
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_has_range
Unexecuted instantiation: zend_ssa.c:_ssa_op1_has_range
Unexecuted instantiation: zend_ssa.c:_ssa_op2_has_range
53
54
#define DEFINE_SSA_OP_MIN_RANGE(opN) \
55
  static zend_always_inline zend_long _ssa_##opN##_min_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
56
5.05k
  { \
57
5.05k
    if (opline->opN##_type == IS_CONST) { \
58
407
      zval *zv = CRT_CONSTANT(opline->opN); \
59
407
      if (Z_TYPE_P(zv) == IS_LONG) { \
60
407
        return Z_LVAL_P(zv); \
61
407
      } \
62
4.65k
    } else if (opline->opN##_type != IS_UNUSED && \
63
4.65k
        ssa->var_info && \
64
4.65k
        ssa_op->opN##_use >= 0 && \
65
4.65k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
66
4.65k
      return ssa->var_info[ssa_op->opN##_use].range.min; \
67
4.65k
    } \
68
5.05k
    return ZEND_LONG_MIN; \
69
5.05k
  } \
Unexecuted instantiation: dce.c:_ssa_op1_min_range
Unexecuted instantiation: dce.c:_ssa_op2_min_range
Unexecuted instantiation: dfa_pass.c:_ssa_op1_min_range
Unexecuted instantiation: dfa_pass.c:_ssa_op2_min_range
Unexecuted instantiation: escape_analysis.c:_ssa_op1_min_range
Unexecuted instantiation: escape_analysis.c:_ssa_op2_min_range
Unexecuted instantiation: sccp.c:_ssa_op1_min_range
Unexecuted instantiation: sccp.c:_ssa_op2_min_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_min_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_min_range
Unexecuted instantiation: zend_dump.c:_ssa_op1_min_range
Unexecuted instantiation: zend_dump.c:_ssa_op2_min_range
Unexecuted instantiation: zend_func_info.c:_ssa_op1_min_range
Unexecuted instantiation: zend_func_info.c:_ssa_op2_min_range
Unexecuted instantiation: zend_optimizer.c:_ssa_op1_min_range
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_min_range
Unexecuted instantiation: zend_ssa.c:_ssa_op1_min_range
Unexecuted instantiation: zend_ssa.c:_ssa_op2_min_range
70
71
#define DEFINE_SSA_OP_MAX_RANGE(opN) \
72
  static zend_always_inline zend_long _ssa_##opN##_max_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
73
5.01k
  { \
74
5.01k
    if (opline->opN##_type == IS_CONST) { \
75
359
      zval *zv = CRT_CONSTANT(opline->opN); \
76
359
      if (Z_TYPE_P(zv) == IS_LONG) { \
77
359
        return Z_LVAL_P(zv); \
78
359
      } \
79
4.65k
    } else if (opline->opN##_type != IS_UNUSED && \
80
4.65k
        ssa->var_info && \
81
4.65k
        ssa_op->opN##_use >= 0 && \
82
4.65k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
83
4.65k
      return ssa->var_info[ssa_op->opN##_use].range.max; \
84
4.65k
    } \
85
5.01k
    return ZEND_LONG_MAX; \
86
5.01k
  } \
Unexecuted instantiation: dce.c:_ssa_op1_max_range
Unexecuted instantiation: dce.c:_ssa_op2_max_range
Unexecuted instantiation: dfa_pass.c:_ssa_op1_max_range
Unexecuted instantiation: dfa_pass.c:_ssa_op2_max_range
Unexecuted instantiation: escape_analysis.c:_ssa_op1_max_range
Unexecuted instantiation: escape_analysis.c:_ssa_op2_max_range
Unexecuted instantiation: sccp.c:_ssa_op1_max_range
Unexecuted instantiation: sccp.c:_ssa_op2_max_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_max_range
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_max_range
Unexecuted instantiation: zend_dump.c:_ssa_op1_max_range
Unexecuted instantiation: zend_dump.c:_ssa_op2_max_range
Unexecuted instantiation: zend_func_info.c:_ssa_op1_max_range
Unexecuted instantiation: zend_func_info.c:_ssa_op2_max_range
Unexecuted instantiation: zend_optimizer.c:_ssa_op1_max_range
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_max_range
Unexecuted instantiation: zend_ssa.c:_ssa_op1_max_range
Unexecuted instantiation: zend_ssa.c:_ssa_op2_max_range
87
88
#define DEFINE_SSA_OP_RANGE_UNDERFLOW(opN) \
89
  static zend_always_inline char _ssa_##opN##_range_underflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
90
4.24k
  { \
91
4.24k
    if (opline->opN##_type == IS_CONST) { \
92
312
      zval *zv = CRT_CONSTANT(opline->opN); \
93
312
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
312
        return 0; \
95
312
      } \
96
3.93k
    } else if (opline->opN##_type != IS_UNUSED && \
97
3.93k
        ssa->var_info && \
98
3.93k
        ssa_op->opN##_use >= 0 && \
99
3.93k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
3.93k
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
3.93k
    } \
102
4.24k
    return 1; \
103
4.24k
  } \
Unexecuted instantiation: zend_jit.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_jit.c:_ssa_op2_range_underflow
Unexecuted instantiation: dce.c:_ssa_op1_range_underflow
Unexecuted instantiation: dce.c:_ssa_op2_range_underflow
Unexecuted instantiation: dfa_pass.c:_ssa_op1_range_underflow
Unexecuted instantiation: dfa_pass.c:_ssa_op2_range_underflow
Unexecuted instantiation: escape_analysis.c:_ssa_op1_range_underflow
Unexecuted instantiation: escape_analysis.c:_ssa_op2_range_underflow
Unexecuted instantiation: sccp.c:_ssa_op1_range_underflow
Unexecuted instantiation: sccp.c:_ssa_op2_range_underflow
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_range_underflow
Unexecuted instantiation: zend_dump.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_dump.c:_ssa_op2_range_underflow
Unexecuted instantiation: zend_func_info.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_func_info.c:_ssa_op2_range_underflow
zend_inference.c:_ssa_op1_range_underflow
Line
Count
Source
90
2.84k
  { \
91
2.84k
    if (opline->opN##_type == IS_CONST) { \
92
56
      zval *zv = CRT_CONSTANT(opline->opN); \
93
56
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
56
        return 0; \
95
56
      } \
96
2.78k
    } else if (opline->opN##_type != IS_UNUSED && \
97
2.78k
        ssa->var_info && \
98
2.78k
        ssa_op->opN##_use >= 0 && \
99
2.78k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
2.78k
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
2.78k
    } \
102
2.84k
    return 1; \
103
2.84k
  } \
zend_inference.c:_ssa_op2_range_underflow
Line
Count
Source
90
1.40k
  { \
91
1.40k
    if (opline->opN##_type == IS_CONST) { \
92
256
      zval *zv = CRT_CONSTANT(opline->opN); \
93
256
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
256
        return 0; \
95
256
      } \
96
1.14k
    } else if (opline->opN##_type != IS_UNUSED && \
97
1.14k
        ssa->var_info && \
98
1.14k
        ssa_op->opN##_use >= 0 && \
99
1.14k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
1.14k
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
1.14k
    } \
102
1.40k
    return 1; \
103
1.40k
  } \
Unexecuted instantiation: zend_optimizer.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_range_underflow
Unexecuted instantiation: zend_ssa.c:_ssa_op1_range_underflow
Unexecuted instantiation: zend_ssa.c:_ssa_op2_range_underflow
104
105
#define DEFINE_SSA_OP_RANGE_OVERFLOW(opN) \
106
  static zend_always_inline char _ssa_##opN##_range_overflow(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
107
3.78k
  { \
108
3.78k
    if (opline->opN##_type == IS_CONST) { \
109
312
      zval *zv = CRT_CONSTANT(opline->opN); \
110
312
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
312
        return 0; \
112
312
      } \
113
3.47k
    } else if (opline->opN##_type != IS_UNUSED && \
114
3.47k
        ssa->var_info && \
115
3.47k
        ssa_op->opN##_use >= 0 && \
116
3.47k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
3.47k
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
3.47k
    } \
119
3.78k
    return 1; \
120
3.78k
  } \
Unexecuted instantiation: zend_jit.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_jit.c:_ssa_op2_range_overflow
Unexecuted instantiation: dce.c:_ssa_op1_range_overflow
Unexecuted instantiation: dce.c:_ssa_op2_range_overflow
Unexecuted instantiation: dfa_pass.c:_ssa_op1_range_overflow
Unexecuted instantiation: dfa_pass.c:_ssa_op2_range_overflow
Unexecuted instantiation: escape_analysis.c:_ssa_op1_range_overflow
Unexecuted instantiation: escape_analysis.c:_ssa_op2_range_overflow
Unexecuted instantiation: sccp.c:_ssa_op1_range_overflow
Unexecuted instantiation: sccp.c:_ssa_op2_range_overflow
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_range_overflow
Unexecuted instantiation: zend_dump.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_dump.c:_ssa_op2_range_overflow
Unexecuted instantiation: zend_func_info.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_func_info.c:_ssa_op2_range_overflow
zend_inference.c:_ssa_op1_range_overflow
Line
Count
Source
107
2.44k
  { \
108
2.44k
    if (opline->opN##_type == IS_CONST) { \
109
56
      zval *zv = CRT_CONSTANT(opline->opN); \
110
56
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
56
        return 0; \
112
56
      } \
113
2.38k
    } else if (opline->opN##_type != IS_UNUSED && \
114
2.38k
        ssa->var_info && \
115
2.38k
        ssa_op->opN##_use >= 0 && \
116
2.38k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
2.38k
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
2.38k
    } \
119
2.44k
    return 1; \
120
2.44k
  } \
zend_inference.c:_ssa_op2_range_overflow
Line
Count
Source
107
1.33k
  { \
108
1.33k
    if (opline->opN##_type == IS_CONST) { \
109
256
      zval *zv = CRT_CONSTANT(opline->opN); \
110
256
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
256
        return 0; \
112
256
      } \
113
1.08k
    } else if (opline->opN##_type != IS_UNUSED && \
114
1.08k
        ssa->var_info && \
115
1.08k
        ssa_op->opN##_use >= 0 && \
116
1.08k
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
1.08k
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
1.08k
    } \
119
1.33k
    return 1; \
120
1.33k
  } \
Unexecuted instantiation: zend_optimizer.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_range_overflow
Unexecuted instantiation: zend_ssa.c:_ssa_op1_range_overflow
Unexecuted instantiation: zend_ssa.c:_ssa_op2_range_overflow
121
122
DEFINE_SSA_OP_HAS_RANGE(op1)
123
2.58k
DEFINE_SSA_OP_MIN_RANGE(op1)
Unexecuted instantiation: zend_jit.c:_ssa_op1_min_range
Unexecuted instantiation: zend_inference.c:_ssa_op1_min_range
124
2.58k
DEFINE_SSA_OP_MAX_RANGE(op1)
Unexecuted instantiation: zend_jit.c:_ssa_op1_max_range
Unexecuted instantiation: zend_inference.c:_ssa_op1_max_range
125
DEFINE_SSA_OP_RANGE_UNDERFLOW(op1)
126
DEFINE_SSA_OP_RANGE_OVERFLOW(op1)
127
DEFINE_SSA_OP_HAS_RANGE(op2)
128
2.47k
DEFINE_SSA_OP_MIN_RANGE(op2)
Unexecuted instantiation: zend_jit.c:_ssa_op2_min_range
Unexecuted instantiation: zend_inference.c:_ssa_op2_min_range
129
2.42k
DEFINE_SSA_OP_MAX_RANGE(op2)
Unexecuted instantiation: zend_jit.c:_ssa_op2_max_range
Unexecuted instantiation: zend_inference.c:_ssa_op2_max_range
130
DEFINE_SSA_OP_RANGE_UNDERFLOW(op2)
131
DEFINE_SSA_OP_RANGE_OVERFLOW(op2)
132
133
6.87k
#define OP1_HAS_RANGE()       (_ssa_op1_has_range (op_array, ssa, opline, ssa_op))
134
2.58k
#define OP1_MIN_RANGE()       (_ssa_op1_min_range (op_array, ssa, opline, ssa_op))
135
2.58k
#define OP1_MAX_RANGE()       (_ssa_op1_max_range (op_array, ssa, opline, ssa_op))
136
4.26k
#define OP1_RANGE_UNDERFLOW() (_ssa_op1_range_underflow (op_array, ssa, opline, ssa_op))
137
3.86k
#define OP1_RANGE_OVERFLOW()  (_ssa_op1_range_overflow (op_array, ssa, opline, ssa_op))
138
3.33k
#define OP2_HAS_RANGE()       (_ssa_op2_has_range (op_array, ssa, opline, ssa_op))
139
2.47k
#define OP2_MIN_RANGE()       (_ssa_op2_min_range (op_array, ssa, opline, ssa_op))
140
2.42k
#define OP2_MAX_RANGE()       (_ssa_op2_max_range (op_array, ssa, opline, ssa_op))
141
2.82k
#define OP2_RANGE_UNDERFLOW() (_ssa_op2_range_underflow (op_array, ssa, opline, ssa_op))
142
2.47k
#define OP2_RANGE_OVERFLOW()  (_ssa_op2_range_overflow (op_array, ssa, opline, ssa_op))
143
144
BEGIN_EXTERN_C()
145
ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv);
146
END_EXTERN_C()
147
148
13.6k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
13.6k
  if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
150
0
    return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
151
13.6k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
13.6k
  } else {
154
13.6k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
13.6k
    if (Z_REFCOUNTED_P(zv)) {
157
1.46k
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
12.1k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
10.4k
      tmp |= MAY_BE_RCN;
160
10.4k
    }
161
13.6k
    return tmp;
162
13.6k
  }
163
13.6k
}
Unexecuted instantiation: zend_jit.c:_const_op_type
Unexecuted instantiation: dce.c:_const_op_type
dfa_pass.c:_const_op_type
Line
Count
Source
148
20
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
20
  if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
150
0
    return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
151
20
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
20
  } else {
154
20
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
20
    if (Z_REFCOUNTED_P(zv)) {
157
3
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
17
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
17
      tmp |= MAY_BE_RCN;
160
17
    }
161
20
    return tmp;
162
20
  }
163
20
}
Unexecuted instantiation: escape_analysis.c:_const_op_type
Unexecuted instantiation: sccp.c:_const_op_type
Unexecuted instantiation: zend_call_graph.c:_const_op_type
Unexecuted instantiation: zend_dump.c:_const_op_type
Unexecuted instantiation: zend_func_info.c:_const_op_type
zend_inference.c:_const_op_type
Line
Count
Source
148
7.21k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
7.21k
  if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
150
0
    return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
151
7.21k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
7.21k
  } else {
154
7.21k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
7.21k
    if (Z_REFCOUNTED_P(zv)) {
157
797
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
6.41k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
5.21k
      tmp |= MAY_BE_RCN;
160
5.21k
    }
161
7.21k
    return tmp;
162
7.21k
  }
163
7.21k
}
zend_optimizer.c:_const_op_type
Line
Count
Source
148
6.37k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
6.37k
  if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
150
0
    return MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
151
6.37k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
6.37k
  } else {
154
6.37k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
6.37k
    if (Z_REFCOUNTED_P(zv)) {
157
665
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
5.71k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
5.16k
      tmp |= MAY_BE_RCN;
160
5.16k
    }
161
6.37k
    return tmp;
162
6.37k
  }
163
6.37k
}
Unexecuted instantiation: zend_ssa.c:_const_op_type
164
165
static zend_always_inline uint32_t get_ssa_var_info(const zend_ssa *ssa, int ssa_var_num)
166
83.3k
{
167
83.3k
  if (ssa->var_info && ssa_var_num >= 0) {
168
67.2k
    return ssa->var_info[ssa_var_num].type;
169
67.2k
  } else {
170
16.0k
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
16.0k
  }
172
83.3k
}
Unexecuted instantiation: zend_jit.c:get_ssa_var_info
dce.c:get_ssa_var_info
Line
Count
Source
166
88
{
167
88
  if (ssa->var_info && ssa_var_num >= 0) {
168
88
    return ssa->var_info[ssa_var_num].type;
169
88
  } else {
170
0
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
0
  }
172
88
}
dfa_pass.c:get_ssa_var_info
Line
Count
Source
166
367
{
167
367
  if (ssa->var_info && ssa_var_num >= 0) {
168
367
    return ssa->var_info[ssa_var_num].type;
169
367
  } else {
170
0
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
0
  }
172
367
}
escape_analysis.c:get_ssa_var_info
Line
Count
Source
166
28
{
167
28
  if (ssa->var_info && ssa_var_num >= 0) {
168
28
    return ssa->var_info[ssa_var_num].type;
169
28
  } else {
170
0
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
0
  }
172
28
}
Unexecuted instantiation: sccp.c:get_ssa_var_info
Unexecuted instantiation: zend_call_graph.c:get_ssa_var_info
Unexecuted instantiation: zend_dump.c:get_ssa_var_info
Unexecuted instantiation: zend_func_info.c:get_ssa_var_info
zend_inference.c:get_ssa_var_info
Line
Count
Source
166
41.6k
{
167
41.6k
  if (ssa->var_info && ssa_var_num >= 0) {
168
31.7k
    return ssa->var_info[ssa_var_num].type;
169
31.7k
  } else {
170
9.90k
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
9.90k
  }
172
41.6k
}
zend_optimizer.c:get_ssa_var_info
Line
Count
Source
166
41.2k
{
167
41.2k
  if (ssa->var_info && ssa_var_num >= 0) {
168
35.0k
    return ssa->var_info[ssa_var_num].type;
169
35.0k
  } else {
170
6.12k
    return MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
171
6.12k
  }
172
41.2k
}
Unexecuted instantiation: zend_ssa.c:get_ssa_var_info
173
174
#define DEFINE_SSA_OP_INFO(opN) \
175
  static zend_always_inline uint32_t _ssa_##opN##_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
176
71.5k
  {                                   \
177
71.5k
    if (opline->opN##_type == IS_CONST) {             \
178
13.6k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
57.9k
    } else { \
180
57.9k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
57.9k
    } \
182
71.5k
  } \
Unexecuted instantiation: zend_jit.c:_ssa_op1_info
Unexecuted instantiation: zend_jit.c:_ssa_op2_info
Unexecuted instantiation: zend_jit.c:_ssa_result_info
dce.c:_ssa_op2_info
Line
Count
Source
176
82
  {                                   \
177
82
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
82
    } else { \
180
82
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
82
    } \
182
82
  } \
dce.c:_ssa_op1_info
Line
Count
Source
176
6
  {                                   \
177
6
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
6
    } else { \
180
6
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
6
    } \
182
6
  } \
Unexecuted instantiation: dce.c:_ssa_result_info
dfa_pass.c:_ssa_op2_info
Line
Count
Source
176
176
  {                                   \
177
176
    if (opline->opN##_type == IS_CONST) {             \
178
8
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
168
    } else { \
180
168
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
168
    } \
182
176
  } \
dfa_pass.c:_ssa_op1_info
Line
Count
Source
176
211
  {                                   \
177
211
    if (opline->opN##_type == IS_CONST) {             \
178
12
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
199
    } else { \
180
199
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
199
    } \
182
211
  } \
Unexecuted instantiation: dfa_pass.c:_ssa_result_info
escape_analysis.c:_ssa_op1_info
Line
Count
Source
176
28
  {                                   \
177
28
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
28
    } else { \
180
28
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
28
    } \
182
28
  } \
Unexecuted instantiation: escape_analysis.c:_ssa_op2_info
Unexecuted instantiation: escape_analysis.c:_ssa_result_info
Unexecuted instantiation: sccp.c:_ssa_op1_info
Unexecuted instantiation: sccp.c:_ssa_op2_info
Unexecuted instantiation: sccp.c:_ssa_result_info
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_info
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_info
Unexecuted instantiation: zend_call_graph.c:_ssa_result_info
Unexecuted instantiation: zend_dump.c:_ssa_op1_info
Unexecuted instantiation: zend_dump.c:_ssa_op2_info
Unexecuted instantiation: zend_dump.c:_ssa_result_info
Unexecuted instantiation: zend_func_info.c:_ssa_op1_info
Unexecuted instantiation: zend_func_info.c:_ssa_op2_info
Unexecuted instantiation: zend_func_info.c:_ssa_result_info
zend_inference.c:_ssa_result_info
Line
Count
Source
176
378
  {                                   \
177
378
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
378
    } else { \
180
378
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
378
    } \
182
378
  } \
zend_inference.c:_ssa_op1_info
Line
Count
Source
176
19.3k
  {                                   \
177
19.3k
    if (opline->opN##_type == IS_CONST) {             \
178
818
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
18.5k
    } else { \
180
18.5k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
18.5k
    } \
182
19.3k
  } \
zend_inference.c:_ssa_op2_info
Line
Count
Source
176
18.9k
  {                                   \
177
18.9k
    if (opline->opN##_type == IS_CONST) {             \
178
6.39k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
12.5k
    } else { \
180
12.5k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
12.5k
    } \
182
18.9k
  } \
zend_optimizer.c:_ssa_op1_info
Line
Count
Source
176
16.1k
  {                                   \
177
16.1k
    if (opline->opN##_type == IS_CONST) {             \
178
851
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
15.3k
    } else { \
180
15.3k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
15.3k
    } \
182
16.1k
  } \
zend_optimizer.c:_ssa_op2_info
Line
Count
Source
176
16.1k
  {                                   \
177
16.1k
    if (opline->opN##_type == IS_CONST) {             \
178
5.52k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
10.6k
    } else { \
180
10.6k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
10.6k
    } \
182
16.1k
  } \
Unexecuted instantiation: zend_optimizer.c:_ssa_result_info
Unexecuted instantiation: zend_ssa.c:_ssa_op1_info
Unexecuted instantiation: zend_ssa.c:_ssa_op2_info
Unexecuted instantiation: zend_ssa.c:_ssa_result_info
183
184
#define DEFINE_SSA_OP_DEF_INFO(opN) \
185
  static zend_always_inline uint32_t _ssa_##opN##_def_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
186
15.2k
  { \
187
15.2k
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
15.2k
  } \
Unexecuted instantiation: zend_jit.c:_ssa_result_def_info
Unexecuted instantiation: zend_jit.c:_ssa_op1_def_info
Unexecuted instantiation: zend_jit.c:_ssa_op2_def_info
Unexecuted instantiation: dce.c:_ssa_op1_def_info
Unexecuted instantiation: dce.c:_ssa_op2_def_info
Unexecuted instantiation: dce.c:_ssa_result_def_info
Unexecuted instantiation: dfa_pass.c:_ssa_op1_def_info
Unexecuted instantiation: dfa_pass.c:_ssa_op2_def_info
Unexecuted instantiation: dfa_pass.c:_ssa_result_def_info
Unexecuted instantiation: escape_analysis.c:_ssa_op1_def_info
Unexecuted instantiation: escape_analysis.c:_ssa_op2_def_info
Unexecuted instantiation: escape_analysis.c:_ssa_result_def_info
Unexecuted instantiation: sccp.c:_ssa_op1_def_info
Unexecuted instantiation: sccp.c:_ssa_op2_def_info
Unexecuted instantiation: sccp.c:_ssa_result_def_info
Unexecuted instantiation: zend_call_graph.c:_ssa_op1_def_info
Unexecuted instantiation: zend_call_graph.c:_ssa_op2_def_info
Unexecuted instantiation: zend_call_graph.c:_ssa_result_def_info
Unexecuted instantiation: zend_dump.c:_ssa_op1_def_info
Unexecuted instantiation: zend_dump.c:_ssa_op2_def_info
Unexecuted instantiation: zend_dump.c:_ssa_result_def_info
Unexecuted instantiation: zend_func_info.c:_ssa_op1_def_info
Unexecuted instantiation: zend_func_info.c:_ssa_op2_def_info
Unexecuted instantiation: zend_func_info.c:_ssa_result_def_info
Unexecuted instantiation: zend_inference.c:_ssa_op1_def_info
Unexecuted instantiation: zend_inference.c:_ssa_op2_def_info
Unexecuted instantiation: zend_inference.c:_ssa_result_def_info
zend_optimizer.c:_ssa_op1_def_info
Line
Count
Source
186
118
  { \
187
118
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
118
  } \
zend_optimizer.c:_ssa_result_def_info
Line
Count
Source
186
15.1k
  { \
187
15.1k
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
15.1k
  } \
Unexecuted instantiation: zend_optimizer.c:_ssa_op2_def_info
Unexecuted instantiation: zend_ssa.c:_ssa_op1_def_info
Unexecuted instantiation: zend_ssa.c:_ssa_op2_def_info
Unexecuted instantiation: zend_ssa.c:_ssa_result_def_info
189
190
191
DEFINE_SSA_OP_INFO(op1)
192
DEFINE_SSA_OP_INFO(op2)
193
DEFINE_SSA_OP_INFO(result)
194
DEFINE_SSA_OP_DEF_INFO(op1)
195
DEFINE_SSA_OP_DEF_INFO(op2)
196
DEFINE_SSA_OP_DEF_INFO(result)
197
198
35.5k
#define OP1_INFO()           (_ssa_op1_info(op_array, ssa, opline, ssa_op))
199
35.4k
#define OP2_INFO()           (_ssa_op2_info(op_array, ssa, opline, ssa_op))
200
234
#define OP1_DATA_INFO()      (_ssa_op1_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL))
201
#define OP2_DATA_INFO()      (_ssa_op2_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL))
202
378
#define RES_USE_INFO()       (_ssa_result_info(op_array, ssa, opline, ssa_op))
203
118
#define OP1_DEF_INFO()       (_ssa_op1_def_info(op_array, ssa, opline, ssa_op))
204
#define OP2_DEF_INFO()       (_ssa_op2_def_info(op_array, ssa, opline, ssa_op))
205
#define OP1_DATA_DEF_INFO()  (_ssa_op1_def_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL))
206
#define OP2_DATA_DEF_INFO()  (_ssa_op2_def_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL))
207
15.1k
#define RES_INFO()           (_ssa_result_def_info(op_array, ssa, opline, ssa_op))
208
209
108
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
210
108
  return (b > 0 && a > ZEND_LONG_MAX - b)
211
99
    || (b < 0 && a < ZEND_LONG_MIN - b);
212
108
}
Unexecuted instantiation: zend_jit.c:zend_add_will_overflow
Unexecuted instantiation: dce.c:zend_add_will_overflow
Unexecuted instantiation: dfa_pass.c:zend_add_will_overflow
Unexecuted instantiation: escape_analysis.c:zend_add_will_overflow
Unexecuted instantiation: sccp.c:zend_add_will_overflow
Unexecuted instantiation: zend_call_graph.c:zend_add_will_overflow
Unexecuted instantiation: zend_dump.c:zend_add_will_overflow
Unexecuted instantiation: zend_func_info.c:zend_add_will_overflow
zend_inference.c:zend_add_will_overflow
Line
Count
Source
209
18
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
210
18
  return (b > 0 && a > ZEND_LONG_MAX - b)
211
9
    || (b < 0 && a < ZEND_LONG_MIN - b);
212
18
}
Unexecuted instantiation: zend_optimizer.c:zend_add_will_overflow
zend_ssa.c:zend_add_will_overflow
Line
Count
Source
209
90
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
210
90
  return (b > 0 && a > ZEND_LONG_MAX - b)
211
90
    || (b < 0 && a < ZEND_LONG_MIN - b);
212
90
}
213
56
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
214
56
  return (b > 0 && a < ZEND_LONG_MIN + b)
215
52
    || (b < 0 && a > ZEND_LONG_MAX + b);
216
56
}
Unexecuted instantiation: zend_jit.c:zend_sub_will_overflow
Unexecuted instantiation: dce.c:zend_sub_will_overflow
Unexecuted instantiation: dfa_pass.c:zend_sub_will_overflow
Unexecuted instantiation: escape_analysis.c:zend_sub_will_overflow
Unexecuted instantiation: sccp.c:zend_sub_will_overflow
Unexecuted instantiation: zend_call_graph.c:zend_sub_will_overflow
Unexecuted instantiation: zend_dump.c:zend_sub_will_overflow
Unexecuted instantiation: zend_func_info.c:zend_sub_will_overflow
zend_inference.c:zend_sub_will_overflow
Line
Count
Source
213
8
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
214
8
  return (b > 0 && a < ZEND_LONG_MIN + b)
215
4
    || (b < 0 && a > ZEND_LONG_MAX + b);
216
8
}
Unexecuted instantiation: zend_optimizer.c:zend_sub_will_overflow
zend_ssa.c:zend_sub_will_overflow
Line
Count
Source
213
48
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
214
48
  return (b > 0 && a < ZEND_LONG_MIN + b)
215
48
    || (b < 0 && a > ZEND_LONG_MAX + b);
216
48
}
217
218
BEGIN_EXTERN_C()
219
220
ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, const zend_ssa *ssa);
221
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
222
ZEND_API zend_result zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
223
224
ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert);
225
226
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
227
228
ZEND_API uint32_t zend_fetch_arg_info_type(
229
  const zend_script *script, const zend_arg_info *arg_info, zend_class_entry **pce);
230
ZEND_API void zend_init_func_return_info(
231
  const zend_op_array *op_array, const zend_script *script, zend_ssa_var_info *ret);
232
uint32_t zend_get_return_info_from_signature_only(
233
    const zend_function *func, const zend_script *script,
234
    zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info);
235
236
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2);
237
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa);
238
239
ZEND_API zend_result zend_update_type_info(
240
  const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script,
241
  const zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes,
242
  zend_long optimization_level);
243
244
END_EXTERN_C()
245
246
#endif /* ZEND_INFERENCE_H */