From: hark110 at 163 dot com
Operating system: All
PHP version: 5.5.1
Package: Performance problem
Bug Type: Feature/Change Request
Bug description:Add call_func() syntax
Description:
------------
now php use call_user_func_array() function dynamic call other function of
unsure paramters, but the function performance slow than $function() call
function and about 50%, but variable functions can not call dynamic
paramters
other, call_user_func() and call_user_func_array() can not call protected
and private method of object
so i think php add call_func syntax instead call function ways
my think is below, use foreach pcode comply SEND_VAR to function:
1. Zend/zend_language_scanner.l add code:
<ST_IN_SCRIPTING>"call_func" {
return T_CALL_FUNC;
}
2.Zend/zend_language_parser.y add code:
find **function_call:** section append code:
| T_CALL_FUNC '(' call_function_name function_call_array_parameters ')'
{ zend_do_end_function_call(&$3, &$$, &$4, 0, 1 TSRMLS_CC);
zend_do_extended_fcall_end(TSRMLS_C);}
then add:
call_function_name:
variable {zend_do_end_variable_parse(&$3, BP_VAR_R, 0
TSRMLS_CC);zend_do_begin_dynamic_function_call(&$3, 0 TSRMLS_CC);}
| T_STRING {$$=$3;zend_do_begin_dynamic_function_call(&$3, 0
TSRMLS_CC);}
;
function_call_array_parameter:
{ Z_LVAL($$.u.constant)=0; }
| expr {zend_do_pass_array_parameters(&$4, ZEND_SEND_VAL,
Z_LVAL($$.u.constant) TSRMLS_CC)}
;
3.Zend/zend_compile.c add zend_do_pass_array_parameters() function:
void zend_do_pass_array_parameters(znode * expr, zend_uchar op, int offset
TSRMLS_DC) /* {{{ */ {
zend_op *opline;
znode last_container;
znode *result;
expr->u.opline_num = get_next_op_number(CG(active_op_array));
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
/* Preform array reset */
opline->opcode = ZEND_FE_RESET;
opline->result.op_type = IS_VAR;
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->op1 = *array;
SET_UNUSED(opline->op2);
opline->extended_value = is_variable ? ZEND_FE_RESET_VARIABLE : 0;
dummy_opline.result = opline->result;
zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof
(zend_op));
/* save the location of FE_FETCH */
//as_token->u.opline_num = get_next_op_number(CG(active_op_array));
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_FE_FETCH;
opline->result.op_type = IS_VAR;
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->op1 = dummy_opline.result;
opline->extended_value = 0;
SET_UNUSED(opline->op2);
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_OP_DATA;
result = opline->result;
zend_do_pass_param(result, op, offset TSRMLS_CC);
SET_UNUSED(opline->op1);
SET_UNUSED(opline->op2);
SET_UNUSED(opline->result);
zend_do_foreach_end(expr)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=65410&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65410&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65410&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65410&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65410&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65410&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65410&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65410&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65410&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65410&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65410&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65410&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65410&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65410&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65410&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65410&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65410&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65410&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65410&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65410&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65410&r=mysqlcfg