@@ -979,24 +979,24 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
979
979
ZEND_API int do_bind_function (const zend_op_array * op_array , const zend_op * opline , HashTable * function_table , zend_bool compile_time ) /* {{{ */
980
980
{
981
981
zend_function * function , * new_function ;
982
- zval * op1 , * op2 ;
982
+ zval * lcname , * rtd_key ;
983
983
984
984
if (compile_time ) {
985
- op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
986
- op2 = CT_CONSTANT_EX ( op_array , opline -> op2 . constant ) ;
985
+ lcname = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
986
+ rtd_key = lcname + 1 ;
987
987
} else {
988
- op1 = RT_CONSTANT (op_array , opline -> op1 );
989
- op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
988
+ lcname = RT_CONSTANT (op_array , opline -> op1 );
989
+ rtd_key = lcname + 1 ;
990
990
}
991
991
992
- function = zend_hash_find_ptr (function_table , Z_STR_P (op1 ));
992
+ function = zend_hash_find_ptr (function_table , Z_STR_P (rtd_key ));
993
993
new_function = zend_arena_alloc (& CG (arena ), sizeof (zend_op_array ));
994
994
memcpy (new_function , function , sizeof (zend_op_array ));
995
- if (zend_hash_add_ptr (function_table , Z_STR_P (op2 ), new_function ) == NULL ) {
995
+ if (zend_hash_add_ptr (function_table , Z_STR_P (lcname ), new_function ) == NULL ) {
996
996
int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR ;
997
997
zend_function * old_function ;
998
998
999
- if ((old_function = zend_hash_find_ptr (function_table , Z_STR_P (op2 ))) != NULL
999
+ if ((old_function = zend_hash_find_ptr (function_table , Z_STR_P (lcname ))) != NULL
1000
1000
&& old_function -> type == ZEND_USER_FUNCTION
1001
1001
&& old_function -> op_array .last > 0 ) {
1002
1002
zend_error_noreturn (error_level , "Cannot redeclare %s() (previously declared in %s:%d)" ,
@@ -1020,21 +1020,21 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opli
1020
1020
ZEND_API zend_class_entry * do_bind_class (const zend_op_array * op_array , const zend_op * opline , HashTable * class_table , zend_bool compile_time ) /* {{{ */
1021
1021
{
1022
1022
zend_class_entry * ce ;
1023
- zval * op1 , * op2 ;
1023
+ zval * lcname , * rtd_key ;
1024
1024
1025
1025
if (compile_time ) {
1026
- op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
1027
- op2 = CT_CONSTANT_EX ( op_array , opline -> op2 . constant ) ;
1026
+ lcname = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
1027
+ rtd_key = lcname + 1 ;
1028
1028
} else {
1029
- op1 = RT_CONSTANT (op_array , opline -> op1 );
1030
- op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
1029
+ lcname = RT_CONSTANT (op_array , opline -> op1 );
1030
+ rtd_key = lcname + 1 ;
1031
1031
}
1032
- if ((ce = zend_hash_find_ptr (class_table , Z_STR_P (op1 ))) == NULL ) {
1033
- zend_error_noreturn (E_COMPILE_ERROR , "Internal Zend error - Missing class information for %s" , Z_STRVAL_P (op1 ));
1032
+ if ((ce = zend_hash_find_ptr (class_table , Z_STR_P (rtd_key ))) == NULL ) {
1033
+ zend_error_noreturn (E_COMPILE_ERROR , "Internal Zend error - Missing class information for %s" , Z_STRVAL_P (rtd_key ));
1034
1034
return NULL ;
1035
1035
}
1036
1036
ce -> refcount ++ ;
1037
- if (zend_hash_add_ptr (class_table , Z_STR_P (op2 ), ce ) == NULL ) {
1037
+ if (zend_hash_add_ptr (class_table , Z_STR_P (lcname ), ce ) == NULL ) {
1038
1038
ce -> refcount -- ;
1039
1039
if (!compile_time ) {
1040
1040
/* If we're in compile time, in practice, it's quite possible
@@ -1057,17 +1057,17 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze
1057
1057
ZEND_API zend_class_entry * do_bind_inherited_class (const zend_op_array * op_array , const zend_op * opline , HashTable * class_table , zend_class_entry * parent_ce , zend_bool compile_time ) /* {{{ */
1058
1058
{
1059
1059
zend_class_entry * ce ;
1060
- zval * op1 , * op2 ;
1060
+ zval * lcname , * rtd_key ;
1061
1061
1062
1062
if (compile_time ) {
1063
- op1 = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
1064
- op2 = CT_CONSTANT_EX ( op_array , opline -> op2 . constant ) ;
1063
+ lcname = CT_CONSTANT_EX (op_array , opline -> op1 .constant );
1064
+ rtd_key = lcname + 1 ;
1065
1065
} else {
1066
- op1 = RT_CONSTANT (op_array , opline -> op1 );
1067
- op2 = RT_CONSTANT ( op_array , opline -> op2 ) ;
1066
+ lcname = RT_CONSTANT (op_array , opline -> op1 );
1067
+ rtd_key = lcname + 1 ;
1068
1068
}
1069
1069
1070
- ce = zend_hash_find_ptr (class_table , Z_STR_P (op1 ));
1070
+ ce = zend_hash_find_ptr (class_table , Z_STR_P (rtd_key ));
1071
1071
1072
1072
if (!ce ) {
1073
1073
if (!compile_time ) {
@@ -1076,12 +1076,12 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
1076
1076
* so we shut up about it. This allows the if (!defined('FOO')) { return; }
1077
1077
* approach to work.
1078
1078
*/
1079
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot declare %s %s, because the name is already in use" , zend_get_object_type (Z_OBJCE_P (op2 )), Z_STRVAL_P (op2 ));
1079
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot declare %s, because the name is already in use" , zend_get_object_type (Z_OBJCE_P (lcname )), Z_STRVAL_P (lcname ));
1080
1080
}
1081
1081
return NULL ;
1082
1082
}
1083
1083
1084
- if (zend_hash_exists (class_table , Z_STR_P (op2 ))) {
1084
+ if (zend_hash_exists (class_table , Z_STR_P (lcname ))) {
1085
1085
zend_error_noreturn (E_COMPILE_ERROR , "Cannot declare %s %s, because the name is already in use" , zend_get_object_type (ce ), ZSTR_VAL (ce -> name ));
1086
1086
}
1087
1087
@@ -1090,7 +1090,7 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
1090
1090
ce -> refcount ++ ;
1091
1091
1092
1092
/* Register the derived class */
1093
- if (zend_hash_add_ptr (class_table , Z_STR_P (op2 ), ce ) == NULL ) {
1093
+ if (zend_hash_add_ptr (class_table , Z_STR_P (lcname ), ce ) == NULL ) {
1094
1094
zend_error_noreturn (E_COMPILE_ERROR , "Cannot declare %s %s, because the name is already in use" , zend_get_object_type (ce ), ZSTR_VAL (ce -> name ));
1095
1095
}
1096
1096
return ce ;
@@ -1164,9 +1164,9 @@ void zend_do_early_binding(void) /* {{{ */
1164
1164
return ;
1165
1165
}
1166
1166
1167
- zend_hash_del (table , Z_STR_P (CT_CONSTANT (opline -> op1 )));
1167
+ zend_hash_del (table , Z_STR_P (CT_CONSTANT (opline -> op1 )+ 1 ));
1168
+ zend_del_literal (CG (active_op_array ), opline -> op1 .constant + 1 );
1168
1169
zend_del_literal (CG (active_op_array ), opline -> op1 .constant );
1169
- zend_del_literal (CG (active_op_array ), opline -> op2 .constant );
1170
1170
MAKE_NOP (opline );
1171
1171
}
1172
1172
/* }}} */
@@ -3590,7 +3590,7 @@ void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
3590
3590
}
3591
3591
class_node .op_type = opline -> result_type ;
3592
3592
class_node .u .op .var = opline -> result .var ;
3593
- opline -> op1 . opline_num = get_next_op_number (CG (active_op_array ));
3593
+ opline -> extended_value = get_next_op_number (CG (active_op_array ));
3594
3594
} else {
3595
3595
zend_compile_class_ref_ex (& class_node , class_ast , ZEND_FETCH_CLASS_EXCEPTION );
3596
3596
}
@@ -5027,7 +5027,7 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
5027
5027
static void zend_begin_func_decl (znode * result , zend_op_array * op_array , zend_ast_decl * decl ) /* {{{ */
5028
5028
{
5029
5029
zend_ast * params_ast = decl -> child [0 ];
5030
- zend_string * name = decl -> name , * lcname ;
5030
+ zend_string * name = decl -> name , * lcname , * key ;
5031
5031
zend_op * opline ;
5032
5032
5033
5033
op_array -> function_name = name = zend_prefix_with_ns (name );
@@ -5049,22 +5049,20 @@ static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_as
5049
5049
ZEND_AUTOLOAD_FUNC_NAME );
5050
5050
}
5051
5051
5052
+ key = zend_build_runtime_definition_key (lcname , decl -> lex_pos );
5053
+ zend_hash_update_ptr (CG (function_table ), key , op_array );
5054
+
5052
5055
if (op_array -> fn_flags & ZEND_ACC_CLOSURE ) {
5053
5056
opline = zend_emit_op_tmp (result , ZEND_DECLARE_LAMBDA_FUNCTION , NULL , NULL );
5057
+ opline -> op1_type = IS_CONST ;
5058
+ LITERAL_STR (opline -> op1 , key );
5054
5059
} else {
5055
5060
opline = get_next_op (CG (active_op_array ));
5056
5061
opline -> opcode = ZEND_DECLARE_FUNCTION ;
5057
- opline -> op2_type = IS_CONST ;
5058
- LITERAL_STR (opline -> op2 , zend_string_copy (lcname ));
5059
- }
5060
-
5061
- {
5062
- zend_string * key = zend_build_runtime_definition_key (lcname , decl -> lex_pos );
5063
-
5064
5062
opline -> op1_type = IS_CONST ;
5065
- LITERAL_STR (opline -> op1 , key );
5066
-
5067
- zend_hash_update_ptr (CG (function_table ), key , op_array );
5063
+ LITERAL_STR (opline -> op1 , zend_string_copy ( lcname ) );
5064
+ /* RTD key is placed after lcname literal in op1 */
5065
+ zend_add_literal_string (CG (active_op_array ), & key );
5068
5066
}
5069
5067
5070
5068
zend_string_release (lcname );
@@ -5492,34 +5490,31 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
5492
5490
5493
5491
GET_NODE (& FC (implementing_class ), opline -> result );
5494
5492
5495
- opline -> op2_type = IS_CONST ;
5496
- LITERAL_STR (opline -> op2 , lcname );
5493
+ opline -> op1_type = IS_CONST ;
5494
+ LITERAL_STR (opline -> op1 , lcname );
5497
5495
5498
5496
if (decl -> flags & ZEND_ACC_ANON_CLASS ) {
5499
5497
if (extends_ast ) {
5500
5498
opline -> opcode = ZEND_DECLARE_ANON_INHERITED_CLASS ;
5501
- opline -> extended_value = extends_node . u . op . var ;
5499
+ SET_NODE ( opline -> op2 , & extends_node ) ;
5502
5500
} else {
5503
5501
opline -> opcode = ZEND_DECLARE_ANON_CLASS ;
5504
5502
}
5505
5503
5506
- opline -> op1_type = IS_UNUSED ;
5507
-
5508
5504
zend_hash_update_ptr (CG (class_table ), lcname , ce );
5509
5505
} else {
5510
5506
zend_string * key ;
5511
5507
5512
5508
if (extends_ast ) {
5513
5509
opline -> opcode = ZEND_DECLARE_INHERITED_CLASS ;
5514
- opline -> extended_value = extends_node . u . op . var ;
5510
+ SET_NODE ( opline -> op2 , & extends_node ) ;
5515
5511
} else {
5516
5512
opline -> opcode = ZEND_DECLARE_CLASS ;
5517
5513
}
5518
5514
5519
5515
key = zend_build_runtime_definition_key (lcname , decl -> lex_pos );
5520
-
5521
- opline -> op1_type = IS_CONST ;
5522
- LITERAL_STR (opline -> op1 , key );
5516
+ /* RTD key is placed after lcname literal in op1 */
5517
+ zend_add_literal_string (CG (active_op_array ), & key );
5523
5518
5524
5519
zend_hash_update_ptr (CG (class_table ), key , ce );
5525
5520
}
0 commit comments