Skip to content

Commit 6f2fc61

Browse files
committed
Zend/Optimizer/zend_func_info.h: remove forward declarations
These were added by commit c88ffa9, but @dstogov himself opposed to the concept of forward declarations, see #10338 (comment) (which I don't agree with - in my opinion, forward declarations are a useful tool to reduce header dependencies). Removing these unnecessary forward declarations requires some fiddling with include directives, because they were inconsistent and fragile previously. (They still are, but this PR does not attempt to change this; it only makes problems caused by the forward declaration removal go away.) Please merge this PR if (and only if) my RFC "include cleanup" (https://wiki.php.net/rfc/include_cleanup) gets rejected, to fix the PHP code base according to the RFC decision.
1 parent 2f65da0 commit 6f2fc61

22 files changed

+32
-19
lines changed

Zend/Optimizer/dfa_pass.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "zend_bitset.h"
2626
#include "zend_cfg.h"
2727
#include "zend_ssa.h"
28-
#include "zend_func_info.h"
2928
#include "zend_call_graph.h"
3029
#include "zend_inference.h"
3130
#include "zend_dump.h"

Zend/Optimizer/zend_call_graph.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
#define ZEND_CALL_GRAPH_H
2121

2222
#include "zend_ssa.h"
23-
#include "zend_func_info.h"
2423
#include "zend_optimizer.h"
2524

2625
typedef struct _zend_send_arg_info {
2726
zend_op *opline;
2827
} zend_send_arg_info;
2928

29+
typedef struct _zend_call_info zend_call_info;
30+
3031
struct _zend_call_info {
3132
zend_op_array *caller_op_array;
3233
zend_op *caller_init_opline;
@@ -42,22 +43,24 @@ struct _zend_call_info {
4243
zend_send_arg_info arg_info[1];
4344
};
4445

45-
struct _zend_func_info {
46+
typedef struct _zend_func_info {
4647
int num;
4748
uint32_t flags;
4849
zend_ssa ssa; /* Static Single Assignment Form */
4950
zend_call_info *caller_info; /* where this function is called from */
5051
zend_call_info *callee_info; /* which functions are called from this one */
5152
zend_call_info **call_map; /* Call info associated with init/call/send opnum */
5253
zend_ssa_var_info return_info;
53-
};
54+
} zend_func_info;
5455

5556
typedef struct _zend_call_graph {
5657
int op_arrays_count;
5758
zend_op_array **op_arrays;
5859
zend_func_info *func_infos;
5960
} zend_call_graph;
6061

62+
#include "zend_func_info.h"
63+
6164
BEGIN_EXTERN_C()
6265

6366
ZEND_API void zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);

Zend/Optimizer/zend_cfg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
#include "zend_compile.h"
2020
#include "zend_cfg.h"
21-
#include "zend_func_info.h"
21+
#include "zend_call_graph.h"
2222
#include "zend_worklist.h"
2323
#include "zend_optimizer.h"
2424
#include "zend_optimizer_internal.h"
2525
#include "zend_sort.h"
26+
#include "zend_arena.h"
27+
#include "zend_globals.h"
2628

2729
static void zend_mark_reachable(zend_op *opcodes, zend_cfg *cfg, zend_basic_block *b) /* {{{ */
2830
{

Zend/Optimizer/zend_cfg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef ZEND_CFG_H
2020
#define ZEND_CFG_H
2121

22+
#include "zend_arena.h"
23+
2224
/* zend_basic_block.flags */
2325
#define ZEND_BB_START (1<<0) /* first block */
2426
#define ZEND_BB_FOLLOW (1<<1) /* follows the next block */

Zend/Optimizer/zend_dump.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "zend_cfg.h"
2121
#include "zend_ssa.h"
2222
#include "zend_inference.h"
23-
#include "zend_func_info.h"
2423
#include "zend_call_graph.h"
2524
#include "zend_dump.h"
2625

Zend/Optimizer/zend_func_info.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
#define ZEND_FUNC_JIT_ON_HOT_COUNTERS (1<<15) /* used by JIT */
4141
#define ZEND_FUNC_JIT_ON_HOT_TRACE (1<<16) /* used by JIT */
4242

43-
44-
typedef struct _zend_func_info zend_func_info;
45-
typedef struct _zend_call_info zend_call_info;
46-
4743
#define ZEND_FUNC_INFO(op_array) \
4844
((zend_func_info*)((op_array)->reserved[zend_func_info_rid]))
4945

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include "zend_compile.h"
2020
#include "zend_generators.h"
2121
#include "zend_inference.h"
22-
#include "zend_func_info.h"
2322
#include "zend_call_graph.h"
2423
#include "zend_closures.h"
2524
#include "zend_worklist.h"
2625
#include "zend_optimizer_internal.h"
26+
#include "zend_globals.h"
2727

2828
/* The used range inference algorithm is described in:
2929
* V. Campos, R. Rodrigues, I. de Assis Costa and F. Pereira.

Zend/Optimizer/zend_optimizer_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define ZEND_OPTIMIZER_INTERNAL_H
2424

2525
#include "zend_ssa.h"
26-
#include "zend_func_info.h"
26+
#include "zend_call_graph.h"
2727

2828
#define ZEND_OP1_LITERAL(opline) (op_array)->literals[(opline)->op1.constant]
2929
#define ZEND_OP1_JMP_ADDR(opline) OP_JMP_ADDR(opline, (opline)->op1)

Zend/zend_compile.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,6 @@ struct _zend_execute_data {
758758

759759
#define ZEND_EXTRA_VALUE 1
760760

761-
#include "zend_globals.h"
762-
763761
typedef enum _zend_compile_position {
764762
ZEND_COMPILE_POSITION_AT_SHEBANG = 0,
765763
ZEND_COMPILE_POSITION_AT_OPEN_TAG,

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "zend_observer.h"
4444
#include "zend_system_id.h"
4545
#include "zend_call_stack.h"
46-
#include "Optimizer/zend_func_info.h"
46+
#include "Optimizer/zend_call_graph.h"
4747

4848
/* Virtual current working directory support */
4949
#include "zend_virtual_cwd.h"

Zend/zend_execute.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "zend_hash.h"
2626
#include "zend_operators.h"
2727
#include "zend_variables.h"
28+
#include "zend_globals.h"
2829

2930
BEGIN_EXTERN_C()
3031
struct _zend_fcall_info;
@@ -186,6 +187,7 @@ ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_
186187
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *pp, zend_class_entry *scope, zend_ast_evaluate_ctx *ctx);
187188

188189
/* dedicated Zend executor functions - do not use! */
190+
typedef struct _zend_vm_stack *zend_vm_stack;
189191
struct _zend_vm_stack {
190192
zval *top;
191193
zval *end;

Zend/zend_extensions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "zend_extensions.h"
2121
#include "zend_system_id.h"
22+
#include "zend_globals.h"
2223

2324
ZEND_API zend_llist zend_extensions;
2425
ZEND_API uint32_t zend_extension_flags = 0;

Zend/zend_float.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "zend.h"
2020
#include "zend_compile.h"
2121
#include "zend_float.h"
22+
#include "zend_globals.h"
2223

2324
ZEND_API void zend_init_fpu(void) /* {{{ */
2425
{

Zend/zend_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "zend_multiply.h"
3939
#include "zend_arena.h"
4040
#include "zend_call_stack.h"
41+
#include "zend_ini.h"
4142

4243
/* Define ZTS if you want a thread-safe Zend */
4344
/*#undef ZTS*/
@@ -66,7 +67,6 @@ END_EXTERN_C()
6667
#undef function_table
6768

6869
typedef struct _zend_vm_stack *zend_vm_stack;
69-
typedef struct _zend_ini_entry zend_ini_entry;
7070
typedef struct _zend_fiber_context zend_fiber_context;
7171
typedef struct _zend_fiber zend_fiber;
7272

Zend/zend_ini.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef ZEND_INI_H
2020
#define ZEND_INI_H
2121

22+
#include "zend_modules.h"
2223
#include "zend_result.h"
2324

2425
#define ZEND_INI_USER (1<<0)
@@ -30,6 +31,8 @@
3031
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
3132
#define ZEND_INI_DISP(name) ZEND_COLD void name(zend_ini_entry *ini_entry, int type)
3233

34+
typedef struct _zend_ini_entry zend_ini_entry;
35+
3336
typedef struct _zend_ini_entry_def {
3437
const char *name;
3538
ZEND_INI_MH((*on_modify));

Zend/zend_language_scanner.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#ifndef ZEND_SCANNER_H
2121
#define ZEND_SCANNER_H
2222

23+
#include "zend_stack.h"
24+
#include "zend_ptr_stack.h"
25+
#include "zend_multibyte.h"
26+
#include "zend_globals.h"
27+
2328
typedef struct _zend_lex_state {
2429
unsigned int yy_leng;
2530
unsigned char *yy_start;

Zend/zend_multibyte.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "zend_operators.h"
2323
#include "zend_multibyte.h"
2424
#include "zend_ini.h"
25+
#include "zend_globals.h"
2526

2627
static const zend_encoding *dummy_encoding_fetcher(const char *encoding_name)
2728
{

Zend/zend_stream.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "zend.h"
2323
#include "zend_compile.h"
2424
#include "zend_stream.h"
25+
#include "zend_globals.h"
2526

2627
ZEND_DLIMPORT int isatty(int fd);
2728

ext/opcache/ZendAccelerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
#include "zend_extensions.h"
5252
#include "zend_compile.h"
53+
#include "zend_types.h"
54+
#include "zend_modules.h"
5355

5456
#include "Optimizer/zend_optimizer.h"
5557
#include "zend_accelerator_hash.h"

ext/opcache/jit/zend_jit.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
#ifdef HAVE_JIT
3535

36-
#include "Optimizer/zend_func_info.h"
3736
#include "Optimizer/zend_ssa.h"
3837
#include "Optimizer/zend_inference.h"
3938
#include "Optimizer/zend_call_graph.h"

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "Zend/zend_API.h"
2626

2727
#include <ZendAccelerator.h>
28-
#include "Optimizer/zend_func_info.h"
2928
#include "Optimizer/zend_call_graph.h"
3029
#include "zend_jit.h"
3130
#if ZEND_JIT_TARGET_X86

ext/opcache/zend_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "zend_attributes.h"
3232

3333
#ifdef HAVE_JIT
34-
# include "Optimizer/zend_func_info.h"
34+
# include "Optimizer/zend_call_graph.h"
3535
# include "jit/zend_jit.h"
3636
#endif
3737

0 commit comments

Comments
 (0)