32
32
#include "zend_language_scanner.h"
33
33
#include "zend_inheritance.h"
34
34
35
- #define CONSTANT_EX (op_array , op ) \
36
- (op_array)->literals[op]
37
-
38
- #define CONSTANT (op ) \
39
- CONSTANT_EX(CG(active_op_array), op)
40
-
41
35
#define SET_NODE (target , src ) do { \
42
36
target ## _type = (src)->op_type; \
43
37
if ((src)->op_type == IS_CONST) { \
50
44
#define GET_NODE (target , src ) do { \
51
45
(target)->op_type = src ## _type; \
52
46
if ((target)->op_type == IS_CONST) { \
53
- ( target)->u.constant = CONSTANT (src.constant ); \
47
+ ZVAL_COPY_VALUE(&( target)->u.constant, CT_CONSTANT (src) ); \
54
48
} else { \
55
49
(target)->u.op = src; \
56
50
} \
@@ -291,11 +285,11 @@ static int lookup_cv(zend_op_array *op_array, zend_string* name TSRMLS_DC) /* {{
291
285
292
286
void zend_del_literal (zend_op_array * op_array , int n ) /* {{{ */
293
287
{
294
- zval_dtor (& CONSTANT_EX (op_array , n ));
288
+ zval_dtor (CT_CONSTANT_EX (op_array , n ));
295
289
if (n + 1 == op_array -> last_literal ) {
296
290
op_array -> last_literal -- ;
297
291
} else {
298
- ZVAL_UNDEF (& CONSTANT_EX (op_array , n ));
292
+ ZVAL_UNDEF (CT_CONSTANT_EX (op_array , n ));
299
293
}
300
294
}
301
295
/* }}} */
@@ -310,7 +304,7 @@ static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int li
310
304
Z_TYPE_FLAGS_P (zv ) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE );
311
305
}
312
306
}
313
- ZVAL_COPY_VALUE (& CONSTANT_EX (op_array , literal_position ), zv );
307
+ ZVAL_COPY_VALUE (CT_CONSTANT_EX (op_array , literal_position ), zv );
314
308
Z_CACHE_SLOT (op_array -> literals [literal_position ]) = -1 ;
315
309
}
316
310
/* }}} */
@@ -752,13 +746,13 @@ static void str_dtor(zval *zv) /* {{{ */ {
752
746
void zend_resolve_goto_label (zend_op_array * op_array , zend_op * opline , int pass2 TSRMLS_DC ) /* {{{ */
753
747
{
754
748
zend_label * dest ;
755
- zend_long current , distance ;
749
+ int current , distance ;
756
750
zval * label ;
757
751
758
752
if (pass2 ) {
759
- label = opline -> op2 . zv ;
753
+ label = RT_CONSTANT ( op_array , opline -> op2 ) ;
760
754
} else {
761
- label = & CONSTANT_EX (op_array , opline -> op2 .constant );
755
+ label = CT_CONSTANT_EX (op_array , opline -> op2 .constant );
762
756
}
763
757
if (CG (context ).labels == NULL ||
764
758
(dest = zend_hash_find_ptr (CG (context ).labels , Z_STR_P (label ))) == NULL ) {
@@ -888,11 +882,11 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opli
888
882
zval * op1 , * op2 ;
889
883
890
884
if (compile_time ) {
891
- op1 = & CONSTANT_EX (op_array , opline -> op1 .constant );
892
- op2 = & CONSTANT_EX (op_array , opline -> op2 .constant );
885
+ op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
886
+ op2 = CT_CONSTANT_EX (op_array , opline -> op2 .constant );
893
887
} else {
894
- op1 = opline -> op1 . zv ;
895
- op2 = opline -> op2 . zv ;
888
+ op1 = RT_CONSTANT ( op_array , opline -> op1 ) ;
889
+ op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
896
890
}
897
891
898
892
function = zend_hash_find_ptr (function_table , Z_STR_P (op1 ));
@@ -928,11 +922,11 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze
928
922
zval * op1 , * op2 ;
929
923
930
924
if (compile_time ) {
931
- op1 = & CONSTANT_EX (op_array , opline -> op1 .constant );
932
- op2 = & CONSTANT_EX (op_array , opline -> op2 .constant );
925
+ op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
926
+ op2 = CT_CONSTANT_EX (op_array , opline -> op2 .constant );
933
927
} else {
934
- op1 = opline -> op1 . zv ;
935
- op2 = opline -> op2 . zv ;
928
+ op1 = RT_CONSTANT ( op_array , opline -> op1 ) ;
929
+ op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
936
930
}
937
931
if ((ce = zend_hash_find_ptr (class_table , Z_STR_P (op1 ))) == NULL ) {
938
932
zend_error_noreturn (E_COMPILE_ERROR , "Internal Zend error - Missing class information for %s" , Z_STRVAL_P (op1 ));
@@ -965,11 +959,11 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
965
959
zval * op1 , * op2 ;
966
960
967
961
if (compile_time ) {
968
- op1 = & CONSTANT_EX (op_array , opline -> op1 .constant );
969
- op2 = & CONSTANT_EX (op_array , opline -> op2 .constant );
962
+ op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
963
+ op2 = CT_CONSTANT_EX (op_array , opline -> op2 .constant );
970
964
} else {
971
- op1 = opline -> op1 . zv ;
972
- op2 = opline -> op2 . zv ;
965
+ op1 = RT_CONSTANT ( op_array , opline -> op1 ) ;
966
+ op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
973
967
}
974
968
975
969
ce = zend_hash_find_ptr (class_table , Z_STR_P (op1 ));
@@ -1032,7 +1026,7 @@ void zend_do_early_binding(TSRMLS_D) /* {{{ */
1032
1026
zval * parent_name ;
1033
1027
zend_class_entry * ce ;
1034
1028
1035
- parent_name = & CONSTANT (fetch_class_opline -> op2 . constant );
1029
+ parent_name = CT_CONSTANT (fetch_class_opline -> op2 );
1036
1030
if (((ce = zend_lookup_class (Z_STR_P (parent_name ) TSRMLS_CC )) == NULL ) ||
1037
1031
((CG (compiler_options ) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES ) &&
1038
1032
(ce -> type == ZEND_INTERNAL_CLASS ))) {
@@ -1071,7 +1065,7 @@ void zend_do_early_binding(TSRMLS_D) /* {{{ */
1071
1065
return ;
1072
1066
}
1073
1067
1074
- zend_hash_del (table , Z_STR ( CONSTANT (opline -> op1 . constant )));
1068
+ zend_hash_del (table , Z_STR_P ( CT_CONSTANT (opline -> op1 )));
1075
1069
zend_del_literal (CG (active_op_array ), opline -> op1 .constant );
1076
1070
zend_del_literal (CG (active_op_array ), opline -> op2 .constant );
1077
1071
MAKE_NOP (opline );
@@ -1087,7 +1081,7 @@ ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS
1087
1081
1088
1082
CG (in_compilation ) = 1 ;
1089
1083
while (opline_num != -1 ) {
1090
- if ((ce = zend_lookup_class (Z_STR_P (op_array -> opcodes [opline_num - 1 ].op2 . zv ) TSRMLS_CC )) != NULL ) {
1084
+ if ((ce = zend_lookup_class (Z_STR_P (RT_CONSTANT ( op_array , op_array -> opcodes [opline_num - 1 ].op2 ) ) TSRMLS_CC )) != NULL ) {
1091
1085
do_bind_inherited_class (op_array , & op_array -> opcodes [opline_num ], EG (class_table ), ce , 0 TSRMLS_CC );
1092
1086
}
1093
1087
opline_num = op_array -> opcodes [opline_num ].result .opline_num ;
@@ -2112,7 +2106,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
2112
2106
2113
2107
opline = zend_delayed_emit_op (result , ZEND_FETCH_OBJ_R , & obj_node , & prop_node TSRMLS_CC );
2114
2108
if (opline -> op2_type == IS_CONST ) {
2115
- convert_to_string (& CONSTANT (opline -> op2 . constant ));
2109
+ convert_to_string (CT_CONSTANT (opline -> op2 ));
2116
2110
zend_alloc_polymorphic_cache_slot (opline -> op2 .constant TSRMLS_CC );
2117
2111
}
2118
2112
@@ -2509,6 +2503,10 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
2509
2503
opline = & CG (active_op_array )-> opcodes [opnum_init ];
2510
2504
opline -> extended_value = arg_count ;
2511
2505
2506
+ if (opline -> opcode == ZEND_INIT_FCALL ) {
2507
+ opline -> op1 .num = zend_vm_calc_used_stack (arg_count , fbc );
2508
+ }
2509
+
2512
2510
call_flags = (opline -> opcode == ZEND_NEW ? ZEND_CALL_CTOR : 0 );
2513
2511
opline = zend_emit_op (result , ZEND_DO_FCALL , NULL , NULL TSRMLS_CC );
2514
2512
opline -> op1 .num = call_flags ;
@@ -2662,7 +2660,7 @@ static int zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t
2662
2660
2663
2661
opline = zend_emit_op (NULL , ZEND_INIT_FCALL , NULL , NULL TSRMLS_CC );
2664
2662
opline -> extended_value = num_args ;
2665
-
2663
+ opline -> op1 . num = zend_vm_calc_used_stack ( num_args , fbc );
2666
2664
opline -> op2_type = IS_CONST ;
2667
2665
LITERAL_STR (opline -> op2 , lcname );
2668
2666
zend_alloc_cache_slot (opline -> op2 .constant TSRMLS_CC );
@@ -3515,7 +3513,7 @@ void zend_compile_switch(zend_ast *ast TSRMLS_DC) /* {{{ */
3515
3513
opline = zend_emit_op (NULL , ZEND_CASE , & expr_node , & cond_node TSRMLS_CC );
3516
3514
SET_NODE (opline -> result , & case_node );
3517
3515
if (opline -> op1_type == IS_CONST ) {
3518
- zval_copy_ctor (& CONSTANT (opline -> op1 . constant ));
3516
+ zval_copy_ctor (CT_CONSTANT (opline -> op1 ));
3519
3517
}
3520
3518
3521
3519
jmpnz_opnums [i ] = zend_emit_cond_jump (ZEND_JMPNZ , & case_node , 0 TSRMLS_CC );
0 commit comments