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
4.77k
#define MAY_BE_GUARD                (1<<28) /* needs type guard */
34
35
#define MAY_HAVE_DTOR \
36
9
  (MAY_BE_OBJECT|MAY_BE_RESOURCE \
37
9
  |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
1.09k
  { \
42
1.09k
    if (opline->opN##_type == IS_CONST) { \
43
194
      zval *zv = CRT_CONSTANT(opline->opN); \
44
194
      return (Z_TYPE_P(zv) == IS_LONG); \
45
902
    } else { \
46
902
      return (opline->opN##_type != IS_UNUSED && \
47
902
            ssa->var_info && \
48
902
            ssa_op->opN##_use >= 0 && \
49
902
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
902
    } \
51
1.09k
    return 0; \
52
1.09k
  } \
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
639
  { \
42
639
    if (opline->opN##_type == IS_CONST) { \
43
72
      zval *zv = CRT_CONSTANT(opline->opN); \
44
72
      return (Z_TYPE_P(zv) == IS_LONG); \
45
567
    } else { \
46
567
      return (opline->opN##_type != IS_UNUSED && \
47
567
            ssa->var_info && \
48
567
            ssa_op->opN##_use >= 0 && \
49
567
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
567
    } \
51
639
    return 0; \
52
639
  } \
zend_inference.c:_ssa_op2_has_range
Line
Count
Source
41
457
  { \
42
457
    if (opline->opN##_type == IS_CONST) { \
43
122
      zval *zv = CRT_CONSTANT(opline->opN); \
44
122
      return (Z_TYPE_P(zv) == IS_LONG); \
45
335
    } else { \
46
335
      return (opline->opN##_type != IS_UNUSED && \
47
335
            ssa->var_info && \
48
335
            ssa_op->opN##_use >= 0 && \
49
335
          ssa->var_info[ssa_op->opN##_use].has_range); \
50
335
    } \
51
457
    return 0; \
52
457
  } \
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
808
  { \
57
808
    if (opline->opN##_type == IS_CONST) { \
58
94
      zval *zv = CRT_CONSTANT(opline->opN); \
59
94
      if (Z_TYPE_P(zv) == IS_LONG) { \
60
94
        return Z_LVAL_P(zv); \
61
94
      } \
62
714
    } else if (opline->opN##_type != IS_UNUSED && \
63
714
        ssa->var_info && \
64
714
        ssa_op->opN##_use >= 0 && \
65
714
        ssa->var_info[ssa_op->opN##_use].has_range) { \
66
714
      return ssa->var_info[ssa_op->opN##_use].range.min; \
67
714
    } \
68
808
    return ZEND_LONG_MIN; \
69
808
  } \
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
808
  { \
74
808
    if (opline->opN##_type == IS_CONST) { \
75
94
      zval *zv = CRT_CONSTANT(opline->opN); \
76
94
      if (Z_TYPE_P(zv) == IS_LONG) { \
77
94
        return Z_LVAL_P(zv); \
78
94
      } \
79
714
    } else if (opline->opN##_type != IS_UNUSED && \
80
714
        ssa->var_info && \
81
714
        ssa_op->opN##_use >= 0 && \
82
714
        ssa->var_info[ssa_op->opN##_use].has_range) { \
83
714
      return ssa->var_info[ssa_op->opN##_use].range.max; \
84
714
    } \
85
808
    return ZEND_LONG_MAX; \
86
808
  } \
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
724
  { \
91
724
    if (opline->opN##_type == IS_CONST) { \
92
94
      zval *zv = CRT_CONSTANT(opline->opN); \
93
94
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
94
        return 0; \
95
94
      } \
96
630
    } else if (opline->opN##_type != IS_UNUSED && \
97
630
        ssa->var_info && \
98
630
        ssa_op->opN##_use >= 0 && \
99
630
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
630
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
630
    } \
102
724
    return 1; \
103
724
  } \
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
471
  { \
91
471
    if (opline->opN##_type == IS_CONST) { \
92
1
      zval *zv = CRT_CONSTANT(opline->opN); \
93
1
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
1
        return 0; \
95
1
      } \
96
470
    } else if (opline->opN##_type != IS_UNUSED && \
97
470
        ssa->var_info && \
98
470
        ssa_op->opN##_use >= 0 && \
99
470
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
470
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
470
    } \
102
471
    return 1; \
103
471
  } \
zend_inference.c:_ssa_op2_range_underflow
Line
Count
Source
90
253
  { \
91
253
    if (opline->opN##_type == IS_CONST) { \
92
93
      zval *zv = CRT_CONSTANT(opline->opN); \
93
93
      if (Z_TYPE_P(zv) == IS_LONG) { \
94
93
        return 0; \
95
93
      } \
96
160
    } else if (opline->opN##_type != IS_UNUSED && \
97
160
        ssa->var_info && \
98
160
        ssa_op->opN##_use >= 0 && \
99
160
        ssa->var_info[ssa_op->opN##_use].has_range) { \
100
160
      return ssa->var_info[ssa_op->opN##_use].range.underflow; \
101
160
    } \
102
253
    return 1; \
103
253
  } \
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
799
  { \
108
799
    if (opline->opN##_type == IS_CONST) { \
109
94
      zval *zv = CRT_CONSTANT(opline->opN); \
110
94
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
94
        return 0; \
112
94
      } \
113
705
    } else if (opline->opN##_type != IS_UNUSED && \
114
705
        ssa->var_info && \
115
705
        ssa_op->opN##_use >= 0 && \
116
705
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
705
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
705
    } \
119
799
    return 1; \
120
799
  } \
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
455
  { \
108
455
    if (opline->opN##_type == IS_CONST) { \
109
1
      zval *zv = CRT_CONSTANT(opline->opN); \
110
1
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
1
        return 0; \
112
1
      } \
113
454
    } else if (opline->opN##_type != IS_UNUSED && \
114
454
        ssa->var_info && \
115
454
        ssa_op->opN##_use >= 0 && \
116
454
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
454
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
454
    } \
119
455
    return 1; \
120
455
  } \
zend_inference.c:_ssa_op2_range_overflow
Line
Count
Source
107
344
  { \
108
344
    if (opline->opN##_type == IS_CONST) { \
109
93
      zval *zv = CRT_CONSTANT(opline->opN); \
110
93
      if (Z_TYPE_P(zv) == IS_LONG) { \
111
93
        return 0; \
112
93
      } \
113
251
    } else if (opline->opN##_type != IS_UNUSED && \
114
251
        ssa->var_info && \
115
251
        ssa_op->opN##_use >= 0 && \
116
251
        ssa->var_info[ssa_op->opN##_use].has_range) { \
117
251
      return ssa->var_info[ssa_op->opN##_use].range.overflow; \
118
251
    } \
119
344
    return 1; \
120
344
  } \
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
455
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
455
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
353
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
353
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
933
#define OP1_HAS_RANGE()       (_ssa_op1_has_range (op_array, ssa, opline, ssa_op))
134
455
#define OP1_MIN_RANGE()       (_ssa_op1_min_range (op_array, ssa, opline, ssa_op))
135
455
#define OP1_MAX_RANGE()       (_ssa_op1_max_range (op_array, ssa, opline, ssa_op))
136
611
#define OP1_RANGE_UNDERFLOW() (_ssa_op1_range_underflow (op_array, ssa, opline, ssa_op))
137
595
#define OP1_RANGE_OVERFLOW()  (_ssa_op1_range_overflow (op_array, ssa, opline, ssa_op))
138
457
#define OP2_HAS_RANGE()       (_ssa_op2_has_range (op_array, ssa, opline, ssa_op))
139
353
#define OP2_MIN_RANGE()       (_ssa_op2_min_range (op_array, ssa, opline, ssa_op))
140
353
#define OP2_MAX_RANGE()       (_ssa_op2_max_range (op_array, ssa, opline, ssa_op))
141
393
#define OP2_RANGE_UNDERFLOW() (_ssa_op2_range_underflow (op_array, ssa, opline, ssa_op))
142
468
#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
4.05k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
4.05k
  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
4.05k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
7
    return zend_array_type_info(zv);
153
4.04k
  } else {
154
4.04k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
4.04k
    if (Z_REFCOUNTED_P(zv)) {
157
1.33k
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
2.71k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
2.25k
      tmp |= MAY_BE_RCN;
160
2.25k
    }
161
4.04k
    return tmp;
162
4.04k
  }
163
4.05k
}
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
25
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
25
  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
25
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
25
  } else {
154
25
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
25
    if (Z_REFCOUNTED_P(zv)) {
157
11
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
14
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
14
      tmp |= MAY_BE_RCN;
160
14
    }
161
25
    return tmp;
162
25
  }
163
25
}
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
2.10k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
2.10k
  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
2.10k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
0
    return zend_array_type_info(zv);
153
2.10k
  } else {
154
2.10k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
2.10k
    if (Z_REFCOUNTED_P(zv)) {
157
677
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
1.42k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
1.12k
      tmp |= MAY_BE_RCN;
160
1.12k
    }
161
2.10k
    return tmp;
162
2.10k
  }
163
2.10k
}
zend_optimizer.c:_const_op_type
Line
Count
Source
148
1.92k
static zend_always_inline uint32_t _const_op_type(const zval *zv) {
149
1.92k
  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
1.92k
  } else if (Z_TYPE_P(zv) == IS_ARRAY) {
152
7
    return zend_array_type_info(zv);
153
1.91k
  } else {
154
1.91k
    uint32_t tmp = (1 << Z_TYPE_P(zv));
155
156
1.91k
    if (Z_REFCOUNTED_P(zv)) {
157
642
      tmp |= MAY_BE_RC1 | MAY_BE_RCN;
158
1.27k
    } else if (Z_TYPE_P(zv) == IS_STRING) {
159
1.11k
      tmp |= MAY_BE_RCN;
160
1.11k
    }
161
1.91k
    return tmp;
162
1.91k
  }
163
1.92k
}
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
15.9k
{
167
15.9k
  if (ssa->var_info && ssa_var_num >= 0) {
168
14.6k
    return ssa->var_info[ssa_var_num].type;
169
14.6k
  } else {
170
1.28k
    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
1.28k
  }
172
15.9k
}
Unexecuted instantiation: zend_jit.c:get_ssa_var_info
dce.c:get_ssa_var_info
Line
Count
Source
166
9
{
167
9
  if (ssa->var_info && ssa_var_num >= 0) {
168
9
    return ssa->var_info[ssa_var_num].type;
169
9
  } 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
9
}
dfa_pass.c:get_ssa_var_info
Line
Count
Source
166
122
{
167
122
  if (ssa->var_info && ssa_var_num >= 0) {
168
122
    return ssa->var_info[ssa_var_num].type;
169
122
  } 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
122
}
escape_analysis.c:get_ssa_var_info
Line
Count
Source
166
3
{
167
3
  if (ssa->var_info && ssa_var_num >= 0) {
168
3
    return ssa->var_info[ssa_var_num].type;
169
3
  } 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
3
}
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
7.34k
{
167
7.34k
  if (ssa->var_info && ssa_var_num >= 0) {
168
6.67k
    return ssa->var_info[ssa_var_num].type;
169
6.67k
  } else {
170
663
    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
663
  }
172
7.34k
}
zend_optimizer.c:get_ssa_var_info
Line
Count
Source
166
8.50k
{
167
8.50k
  if (ssa->var_info && ssa_var_num >= 0) {
168
7.87k
    return ssa->var_info[ssa_var_num].type;
169
7.87k
  } else {
170
625
    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
625
  }
172
8.50k
}
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
15.0k
  {                                   \
177
15.0k
    if (opline->opN##_type == IS_CONST) {             \
178
4.05k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
10.9k
    } else { \
180
10.9k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
10.9k
    } \
182
15.0k
  } \
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
9
  {                                   \
177
9
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
9
    } else { \
180
9
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
9
    } \
182
9
  } \
Unexecuted instantiation: dce.c:_ssa_op1_info
Unexecuted instantiation: dce.c:_ssa_result_info
dfa_pass.c:_ssa_op2_info
Line
Count
Source
176
33
  {                                   \
177
33
    if (opline->opN##_type == IS_CONST) {             \
178
8
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
25
    } else { \
180
25
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
25
    } \
182
33
  } \
dfa_pass.c:_ssa_op1_info
Line
Count
Source
176
114
  {                                   \
177
114
    if (opline->opN##_type == IS_CONST) {             \
178
17
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
97
    } else { \
180
97
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
97
    } \
182
114
  } \
Unexecuted instantiation: dfa_pass.c:_ssa_result_info
escape_analysis.c:_ssa_op1_info
Line
Count
Source
176
2
  {                                   \
177
2
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
2
    } else { \
180
2
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
2
    } \
182
2
  } \
escape_analysis.c:_ssa_op2_info
Line
Count
Source
176
1
  {                                   \
177
1
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
1
    } else { \
180
1
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
1
    } \
182
1
  } \
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
10
  {                                   \
177
10
    if (opline->opN##_type == IS_CONST) {             \
178
0
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
10
    } else { \
180
10
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
10
    } \
182
10
  } \
zend_inference.c:_ssa_op1_info
Line
Count
Source
176
3.86k
  {                                   \
177
3.86k
    if (opline->opN##_type == IS_CONST) {             \
178
187
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
3.67k
    } else { \
180
3.67k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
3.67k
    } \
182
3.86k
  } \
zend_inference.c:_ssa_op2_info
Line
Count
Source
176
3.82k
  {                                   \
177
3.82k
    if (opline->opN##_type == IS_CONST) {             \
178
1.91k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
1.91k
    } else { \
180
1.91k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
1.91k
    } \
182
3.82k
  } \
zend_optimizer.c:_ssa_op1_info
Line
Count
Source
176
3.59k
  {                                   \
177
3.59k
    if (opline->opN##_type == IS_CONST) {             \
178
219
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
3.37k
    } else { \
180
3.37k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
3.37k
    } \
182
3.59k
  } \
zend_optimizer.c:_ssa_op2_info
Line
Count
Source
176
3.59k
  {                                   \
177
3.59k
    if (opline->opN##_type == IS_CONST) {             \
178
1.70k
      return _const_op_type(CRT_CONSTANT(opline->opN)); \
179
1.88k
    } else { \
180
1.88k
      return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \
181
1.88k
    } \
182
3.59k
  } \
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
3.24k
  { \
187
3.24k
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
3.24k
  } \
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
30
  { \
187
30
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
30
  } \
zend_optimizer.c:_ssa_result_def_info
Line
Count
Source
186
3.21k
  { \
187
3.21k
    return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \
188
3.21k
  } \
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
7.56k
#define OP1_INFO()           (_ssa_op1_info(op_array, ssa, opline, ssa_op))
199
7.46k
#define OP2_INFO()           (_ssa_op2_info(op_array, ssa, opline, ssa_op))
200
0
#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
10
#define RES_USE_INFO()       (_ssa_result_info(op_array, ssa, opline, ssa_op))
203
30
#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
3.21k
#define RES_INFO()           (_ssa_result_def_info(op_array, ssa, opline, ssa_op))
208
209
61
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
210
61
  return (b > 0 && a > ZEND_LONG_MAX - b)
211
61
    || (b < 0 && a < ZEND_LONG_MIN - b);
212
61
}
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
Unexecuted instantiation: zend_inference.c:zend_add_will_overflow
Unexecuted instantiation: zend_optimizer.c:zend_add_will_overflow
zend_ssa.c:zend_add_will_overflow
Line
Count
Source
209
61
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
210
61
  return (b > 0 && a > ZEND_LONG_MAX - b)
211
61
    || (b < 0 && a < ZEND_LONG_MIN - b);
212
61
}
213
0
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
214
0
  return (b > 0 && a < ZEND_LONG_MIN + b)
215
0
    || (b < 0 && a > ZEND_LONG_MAX + b);
216
0
}
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
Unexecuted instantiation: zend_inference.c:zend_sub_will_overflow
Unexecuted instantiation: zend_optimizer.c:zend_sub_will_overflow
Unexecuted instantiation: zend_ssa.c:zend_sub_will_overflow
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 */