Skip to content

Commit 4f5f72c

Browse files
committed
Remove ZEND_ACC_INHERITED flag
It is equivalent to checking ce->parent != NULL. Just adds more state that needs to be kept in sync.
1 parent ac89139 commit 4f5f72c

File tree

5 files changed

+22
-33
lines changed

5 files changed

+22
-33
lines changed

Zend/zend_compile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6606,7 +6606,6 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
66066606
if (extends_ast) {
66076607
ce->parent_name =
66086608
zend_resolve_const_class_name_reference(extends_ast, "class name");
6609-
ce->ce_flags |= ZEND_ACC_INHERITED;
66106609
}
66116610

66126611
CG(active_class_entry) = ce;

Zend/zend_compile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ typedef struct _zend_oparray_context {
229229
/* op_array or class is preloaded | | | */
230230
#define ZEND_ACC_PRELOADED (1 << 10) /* X | X | | */
231231
/* | | | */
232-
/* Class Flags (unused: 24...) | | | */
232+
/* Class Flags (unused: 13, 24...) | | | */
233233
/* =========== | | | */
234234
/* | | | */
235235
/* Special class types | | | */
@@ -251,9 +251,6 @@ typedef struct _zend_oparray_context {
251251
/* Class constants updated | | | */
252252
#define ZEND_ACC_CONSTANTS_UPDATED (1 << 12) /* X | | | */
253253
/* | | | */
254-
/* Class extends another class | | | */
255-
#define ZEND_ACC_INHERITED (1 << 13) /* X | | | */
256-
/* | | | */
257254
/* Class implements interface(s) | | | */
258255
#define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 14) /* X | | | */
259256
/* | | | */

ext/opcache/Optimizer/escape_analysis.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
177177
/* objects with destructors should escape */
178178
if (opline->op1_type == IS_CONST) {
179179
zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT(opline->op1)+1));
180-
uint32_t forbidden_flags = ZEND_ACC_INHERITED
180+
uint32_t forbidden_flags =
181181
/* These flags will always cause an exception */
182-
| ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
182+
ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
183183
| ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT;
184-
if (ce && !ce->create_object && !ce->constructor &&
184+
if (ce && !ce->parent && !ce->create_object && !ce->constructor &&
185185
!ce->destructor && !ce->__get && !ce->__set &&
186186
!(ce->ce_flags & forbidden_flags) &&
187187
(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
@@ -247,8 +247,7 @@ static int is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int var
247247
if (opline->op1_type == IS_CONST) {
248248
zend_class_entry *ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT(opline->op1)+1));
249249
if (ce && !ce->create_object && !ce->constructor &&
250-
!ce->destructor && !ce->__get && !ce->__set &&
251-
!(ce->ce_flags & ZEND_ACC_INHERITED)) {
250+
!ce->destructor && !ce->__get && !ce->__set && !ce->parent) {
252251
return 1;
253252
}
254253
}

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,8 +4538,7 @@ int zend_may_throw(const zend_op *opline, const zend_op_array *op_array, zend_ss
45384538
zend_class_entry *ce = var_info->ce;
45394539

45404540
if (var_info->is_instanceof ||
4541-
!ce || ce->create_object || ce->__get || ce->__set ||
4542-
(ce->ce_flags & ZEND_ACC_INHERITED)) {
4541+
!ce || ce->create_object || ce->__get || ce->__set || ce->parent) {
45434542
return 1;
45444543
}
45454544

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8842,28 +8842,23 @@ static uint32_t zend_get_known_property_offset(zend_class_entry *ce, zend_string
88428842
return ZEND_WRONG_PROPERTY_OFFSET;
88438843
}
88448844

8845-
if (ce->ce_flags & ZEND_ACC_INHERITED) {
8846-
if (!ce->parent) {
8847-
/* property offsets may be changed by inheritance */
8848-
return ZEND_WRONG_PROPERTY_OFFSET;
8849-
} else {
8850-
zend_class_entry *parent = ce->parent;
8845+
if (ce->parent) {
8846+
zend_class_entry *parent = ce->parent;
88518847

8852-
do {
8853-
if (parent->type == ZEND_INTERNAL_CLASS) {
8854-
break;
8855-
} else if (parent->info.user.filename != filename) {
8856-
/* some of parents class declarations might be changed infdependently */
8857-
/* TODO: this check may be not enough, because even
8858-
* in the same it's possible to conditionally define
8859-
* few classes with the same name, and "parent" may
8860-
* change from request to request.
8861-
*/
8862-
return ZEND_WRONG_PROPERTY_OFFSET;
8863-
}
8864-
parent = parent->parent;
8865-
} while (parent);
8866-
}
8848+
do {
8849+
if (parent->type == ZEND_INTERNAL_CLASS) {
8850+
break;
8851+
} else if (parent->info.user.filename != filename) {
8852+
/* some of parents class declarations might be changed infdependently */
8853+
/* TODO: this check may be not enough, because even
8854+
* in the same it's possible to conditionally define
8855+
* few classes with the same name, and "parent" may
8856+
* change from request to request.
8857+
*/
8858+
return ZEND_WRONG_PROPERTY_OFFSET;
8859+
}
8860+
parent = parent->parent;
8861+
} while (parent);
88678862
}
88688863

88698864
info = (zend_property_info*)zend_hash_find_ptr(&ce->properties_info, member);

0 commit comments

Comments
 (0)