summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_compile.c17
-rw-r--r--Zend/zend_compile.h2
-rw-r--r--Zend/zend_inheritance.c4
-rw-r--r--Zend/zend_inheritance.h2
-rw-r--r--Zend/zend_vm_def.h6
-rw-r--r--Zend/zend_vm_execute.h6
-rw-r--r--ext/opcache/Optimizer/compact_literals.c5
-rw-r--r--ext/opcache/ZendAccelerator.c2
8 files changed, 29 insertions, 15 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b2b057eda5..f9142d074a 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1047,7 +1047,7 @@ ZEND_API int do_bind_function(zval *lcname) /* {{{ */
}
/* }}} */
-ZEND_API int do_bind_class(zval *lcname) /* {{{ */
+ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */
{
zend_class_entry *ce;
zval *rtd_key, *zv;
@@ -1074,7 +1074,7 @@ ZEND_API int do_bind_class(zval *lcname) /* {{{ */
return FAILURE;
}
- zend_do_link_class(ce);
+ zend_do_link_class(ce, lc_parent_name);
return SUCCESS;
}
/* }}} */
@@ -1141,9 +1141,11 @@ ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array, uint3
const zend_op *opline = &op_array->opcodes[opline_num];
zval *lcname = RT_CONSTANT(opline, opline->op1);
zend_class_entry *ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname + 1));
- zend_class_entry *parent_ce = zend_lookup_class(ce->parent_name);
+ zend_string *lc_parent_name = Z_STR_P(RT_CONSTANT(opline, opline->op2));
+ zend_class_entry *parent_ce = zend_lookup_class_ex(ce->parent_name, lc_parent_name, 0);
+
if (ce && parent_ce && zend_can_early_bind(ce, parent_ce)) {
- do_bind_class(lcname);
+ do_bind_class(lcname, lc_parent_name);
}
opline_num = op_array->opcodes[opline_num].result.opline_num;
}
@@ -6342,6 +6344,13 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
opline = get_next_op();
+ if (ce->parent_name) {
+ /* Lowercased parent name */
+ zend_string *lc_parent_name = zend_string_tolower(ce->parent_name);
+ opline->op2_type = IS_CONST;
+ LITERAL_STR(opline->op2, lc_parent_name);
+ }
+
opline->op1_type = IS_CONST;
LITERAL_STR(opline->op1, lcname);
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 3993274cd1..e40ff99625 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -747,7 +747,7 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast);
void zend_do_free(znode *op1);
ZEND_API int do_bind_function(zval *lcname);
-ZEND_API int do_bind_class(zval *lcname);
+ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name);
ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array);
ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array, uint32_t first_early_binding_opline);
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 15bf4d3c56..d9d2ba2142 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -2286,11 +2286,11 @@ static void report_variance_errors(zend_class_entry *ce) {
zend_hash_index_del(all_obligations, num_key);
}
-ZEND_API void zend_do_link_class(zend_class_entry *ce) /* {{{ */
+ZEND_API void zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */
{
if (ce->parent_name) {
zend_class_entry *parent = zend_fetch_class_by_name(
- ce->parent_name, NULL, ZEND_FETCH_CLASS_ALLOW_UNLINKED);
+ ce->parent_name, lc_parent_name, ZEND_FETCH_CLASS_ALLOW_UNLINKED);
if (!(parent->ce_flags & ZEND_ACC_LINKED)) {
add_dependency_obligation(ce, parent);
}
diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h
index 6b39cb9c35..d5d624cf20 100644
--- a/Zend/zend_inheritance.h
+++ b/Zend/zend_inheritance.h
@@ -27,7 +27,7 @@ BEGIN_EXTERN_C()
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface);
ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
-ZEND_API void zend_do_link_class(zend_class_entry *ce);
+ZEND_API void zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name);
void zend_verify_abstract_class(zend_class_entry *ce);
void zend_build_properties_info_table(zend_class_entry *ce);
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index bce6a16c7a..195a5599fd 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -7132,7 +7132,7 @@ ZEND_VM_HANDLER(139, ZEND_DECLARE_CLASS, CONST, ANY)
USE_OPLINE
SAVE_OPLINE();
- do_bind_class(RT_CONSTANT(opline, opline->op1));
+ do_bind_class(RT_CONSTANT(opline, opline->op1), (OP2_TYPE == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -7145,7 +7145,7 @@ ZEND_VM_HANDLER(145, ZEND_DECLARE_CLASS_DELAYED, CONST, ANY)
if ((zce = zend_hash_find_ex(EG(class_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)), 1)) == NULL ||
((orig_zce = zend_hash_find_ex(EG(class_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)+1), 1)) != NULL &&
Z_CE_P(zce) != Z_CE_P(orig_zce))) {
- do_bind_class(RT_CONSTANT(opline, opline->op1));
+ do_bind_class(RT_CONSTANT(opline, opline->op1), (OP2_TYPE == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -7166,7 +7166,7 @@ ZEND_VM_HANDLER(171, ZEND_DECLARE_ANON_CLASS, ANY, ANY, JMP_ADDR)
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
- zend_do_link_class(ce);
+ zend_do_link_class(ce, (OP2_TYPE == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 1f8edb65dd..f87142a071 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -2097,7 +2097,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_ANON_CLASS_SPEC_HANDLE
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
- zend_do_link_class(ce);
+ zend_do_link_class(ce, (opline->op2_type == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -4017,7 +4017,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_CLASS_SPEC_CONST_HANDL
USE_OPLINE
SAVE_OPLINE();
- do_bind_class(RT_CONSTANT(opline, opline->op1));
+ do_bind_class(RT_CONSTANT(opline, opline->op1), (opline->op2_type == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -4030,7 +4030,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_CLASS_DELAYED_SPEC_CON
if ((zce = zend_hash_find_ex(EG(class_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)), 1)) == NULL ||
((orig_zce = zend_hash_find_ex(EG(class_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)+1), 1)) != NULL &&
Z_CE_P(zce) != Z_CE_P(orig_zce))) {
- do_bind_class(RT_CONSTANT(opline, opline->op1));
+ do_bind_class(RT_CONSTANT(opline, opline->op1), (opline->op2_type == IS_CONST) ? Z_STR_P(RT_CONSTANT(opline, opline->op2)) : NULL);
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index ec80d5e553..ec01302aac 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -270,9 +270,14 @@ literals_handle_static_prop:
LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1);
break;
case ZEND_DECLARE_FUNCTION:
+ LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 2);
+ break;
case ZEND_DECLARE_CLASS:
case ZEND_DECLARE_CLASS_DELAYED:
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 2);
+ if (opline->op2_type == IS_CONST) {
+ LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1);
+ }
break;
case ZEND_ISSET_ISEMPTY_DIM_OBJ:
case ZEND_ASSIGN_DIM:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 61822aa0ba..03d6a22906 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -3636,7 +3636,7 @@ static void preload_link(void)
} else {
CG(zend_lineno) = ce->info.user.line_start;
}
- zend_do_link_class(ce);
+ zend_do_link_class(ce, NULL);
CG(in_compilation) = 0;
CG(compiled_filename) = NULL;