Skip to content

Commit

Permalink
Support for class aliasses
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Nov 7, 2018
1 parent 08ffc9a commit cef0d67
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 5 additions & 1 deletion ext/opcache/Optimizer/zend_call_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static int zend_op_array_collect(zend_call_graph *call_graph, zend_op_array *op_
static int zend_foreach_op_array(zend_call_graph *call_graph, zend_script *script, zend_op_array_func_t func)
{
zend_class_entry *ce;
zend_string *key;
zend_op_array *op_array;

if (func(call_graph, &script->main_op_array) != SUCCESS) {
Expand All @@ -65,7 +66,10 @@ static int zend_foreach_op_array(zend_call_graph *call_graph, zend_script *scrip
}
} ZEND_HASH_FOREACH_END();

ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
ZEND_HASH_FOREACH_STR_KEY_PTR(&script->class_table, key, ce) {
if (ce->refcount > 1 && !zend_string_equals_ci(key, ce->name)) {
continue;
}
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
if (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
if (func(call_graph, op_array) != SUCCESS) {
Expand Down
16 changes: 13 additions & 3 deletions ext/opcache/Optimizer/zend_optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array)
int zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level)
{
zend_class_entry *ce;
zend_string *key;
zend_op_array *op_array;
zend_string *name;
zend_optimizer_ctx ctx;
Expand All @@ -1440,7 +1441,10 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
zend_optimize_op_array(op_array, &ctx);
} ZEND_HASH_FOREACH_END();

ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
ZEND_HASH_FOREACH_STR_KEY_PTR(&script->class_table, key, ce) {
if (ce->refcount > 1 && !zend_string_equals_ci(key, ce->name)) {
continue;
}
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, name, op_array) {
if (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
zend_optimize_op_array(op_array, &ctx);
Expand Down Expand Up @@ -1544,7 +1548,10 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
zend_adjust_fcall_stack_size(op_array, &ctx);
} ZEND_HASH_FOREACH_END();

ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
ZEND_HASH_FOREACH_STR_KEY_PTR(&script->class_table, key, ce) {
if (ce->refcount > 1 && !zend_string_equals_ci(key, ce->name)) {
continue;
}
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, name, op_array) {
if (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
zend_adjust_fcall_stack_size(op_array, &ctx);
Expand All @@ -1553,7 +1560,10 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
} ZEND_HASH_FOREACH_END();
}

ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
ZEND_HASH_FOREACH_STR_KEY_PTR(&script->class_table, key, ce) {
if (ce->refcount > 1 && !zend_string_equals_ci(key, ce->name)) {
continue;
}
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, name, op_array) {
if (op_array->scope != ce && op_array->type == ZEND_USER_FUNCTION) {
zend_op_array *orig_op_array =
Expand Down
9 changes: 7 additions & 2 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,15 @@ static ZEND_FUNCTION(opcache_get_status)

if (zend_hash_num_elements(&ZCSG(preload_script)->script.class_table)) {
zend_class_entry *ce;
zend_string *key;

array_init(&scripts);
ZEND_HASH_FOREACH_PTR(&ZCSG(preload_script)->script.class_table, ce) {
add_next_index_str(&scripts, ce->name);
ZEND_HASH_FOREACH_STR_KEY_PTR(&ZCSG(preload_script)->script.class_table, key, ce) {
if (ce->refcount > 1 && !zend_string_equals_ci(key, ce->name)) {
add_next_index_str(&scripts, key);
} else {
add_next_index_str(&scripts, ce->name);
}
} ZEND_HASH_FOREACH_END();
add_assoc_zval(&statistics, "classes", &scripts);
}
Expand Down

0 comments on commit cef0d67

Please sign in to comment.