From: Dmitry Stogov Date: Thu, 14 Apr 2016 13:07:28 +0000 (+0300) Subject: Use DO_FCALL_BY_NAME instead of DO_FCALL, if possible X-Git-Tag: php-7.1.0alpha1~324 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b73517c1a1a30fb64f0f8f291db3c3a5f312caba;p=php Use DO_FCALL_BY_NAME instead of DO_FCALL, if possible --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index da2c83c55e..c6234f1088 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3132,26 +3132,30 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */ } /* }}} */ -ZEND_API zend_uchar zend_get_call_op(zend_uchar init_op, zend_function *fbc) /* {{{ */ +ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc) /* {{{ */ { - if (fbc) { + if (fbc && init_op->opcode == ZEND_INIT_FCALL) { if (fbc->type == ZEND_INTERNAL_FUNCTION) { - if (!zend_execute_internal && - !fbc->common.scope && - !(fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_HAS_TYPE_HINTS|ZEND_ACC_RETURN_REFERENCE))) { - return ZEND_DO_ICALL; + if (!zend_execute_internal) { + if (!(fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_HAS_TYPE_HINTS|ZEND_ACC_RETURN_REFERENCE))) { + return ZEND_DO_ICALL; + } else { + return ZEND_DO_FCALL_BY_NAME; + } } } else { - if (zend_execute_ex == execute_ex && - !fbc->common.scope && - !(fbc->common.fn_flags & ZEND_ACC_GENERATOR)) { - return ZEND_DO_UCALL; + if (zend_execute_ex == execute_ex) { + if (!(fbc->common.fn_flags & ZEND_ACC_GENERATOR)) { + return ZEND_DO_UCALL; + } else { + return ZEND_DO_FCALL_BY_NAME; + } } } } else if (zend_execute_ex == execute_ex && !zend_execute_internal && - (init_op == ZEND_INIT_FCALL_BY_NAME || - init_op == ZEND_INIT_NS_FCALL_BY_NAME)) { + (init_op->opcode == ZEND_INIT_FCALL_BY_NAME || + init_op->opcode == ZEND_INIT_NS_FCALL_BY_NAME)) { return ZEND_DO_FCALL_BY_NAME; } return ZEND_DO_FCALL; @@ -3177,7 +3181,7 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function * } call_flags = (opline->opcode == ZEND_NEW ? ZEND_CALL_CTOR : 0); - opline = zend_emit_op(result, zend_get_call_op(opline->opcode, fbc), NULL, NULL); + opline = zend_emit_op(result, zend_get_call_op(opline, fbc), NULL, NULL); opline->op1.num = call_flags; zend_do_extended_fcall_end(); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 833aeab297..8fe291f443 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -786,7 +786,7 @@ ZEND_API zend_bool zend_is_compiling(void); ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers); uint32_t zend_get_class_fetch_type(zend_string *name); -ZEND_API zend_uchar zend_get_call_op(zend_uchar init_op, zend_function *fbc); +ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc); typedef zend_bool (*zend_auto_global_callback)(zend_string *name); typedef struct _zend_auto_global { diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c index 8af82e4137..55612d7fa0 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -109,7 +109,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) Z_CACHE_SLOT(op_array->literals[fcall->op2.constant + 1]) = Z_CACHE_SLOT(op_array->literals[fcall->op2.constant]); literal_dtor(&ZEND_OP2_LITERAL(fcall)); fcall->op2.constant = fcall->op2.constant + 1; - opline->opcode = zend_get_call_op(ZEND_INIT_FCALL, call_stack[call].func); + opline->opcode = zend_get_call_op(fcall, call_stack[call].func); } else if (fcall->opcode == ZEND_INIT_NS_FCALL_BY_NAME) { fcall->opcode = ZEND_INIT_FCALL; fcall->op1.num = zend_vm_calc_used_stack(fcall->extended_value, call_stack[call].func); @@ -117,7 +117,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) literal_dtor(&op_array->literals[fcall->op2.constant]); literal_dtor(&op_array->literals[fcall->op2.constant + 2]); fcall->op2.constant = fcall->op2.constant + 1; - opline->opcode = zend_get_call_op(ZEND_INIT_FCALL, call_stack[call].func); + opline->opcode = zend_get_call_op(fcall, call_stack[call].func); } else if (fcall->opcode == ZEND_INIT_STATIC_METHOD_CALL) { /* We don't have specialized opcodes for this, do nothing */ } else {