cvs: ZendEngine2(PHP_5_3) / zend_compile.c zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h
| From: | Dmitry Stogov | Date: | Thu, 22 Nov 2007 09:02:57 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_3) / zend_compile.c zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-6202@lists.php.net to get a copy of this message | ||
dmitry Thu Nov 22 09:02:57 2007 UTC
Modified files: (Branch: PHP_5_3)
/ZendEngine2 zend_compile.c zend_vm_def.h zend_vm_execute.h
zend_vm_opcodes.h
Log:
Speed-up of ZEND_DO_FCALL and ZEND_INIT_FCALL_BY_NAME by lowercasing and calculating hash values
at compile time.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.23&r2=1.647.2.27.2.41.2.24&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.23 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.24 --- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.23 Wed Nov 21 09:41:33 2007 +++ ZendEngine2/zend_compile.c Thu Nov 22 09:02:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.23 2007/11/21 09:41:33 johannes Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.24 2007/11/22 09:02:53 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1446,8 +1446,16 @@ zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_INIT_FCALL_BY_NAME; opline->op2 = *left_bracket; - opline->extended_value = 0; - SET_UNUSED(opline->op1); + if (opline->op2.op_type == IS_CONST) { + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + } else { + opline->extended_value = 0; + SET_UNUSED(opline->op1); + } } zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); @@ -1474,19 +1482,42 @@ zend_op *opline; opline = get_next_op(CG(active_op_array) TSRMLS_CC); - opline->opcode = ZEND_INIT_FCALL_BY_NAME; - opline->op2 = *function_name; - opline->extended_value = 0; if (prefix_len) { /* In run-time PHP will check for function with full name and internal function with short name */ + opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME; + opline->op2 = *function_name; + opline->extended_value = 0; opline->op1.op_type = IS_CONST; - ZVAL_LONG(&opline->op1.u.constant, prefix_len); + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_OP_DATA; + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(function_name->u.constant) - prefix_len; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(function_name->u.constant) + prefix_len, Z_STRLEN(opline->op1.u.constant)); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); } else { - SET_UNUSED(opline->op1); + opline->opcode = ZEND_INIT_FCALL_BY_NAME; + opline->op2 = *function_name; + if (opline->op2.op_type == IS_CONST) { + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + } else { + opline->extended_value = 0; + SET_UNUSED(opline->op1); + } } + + zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); zend_do_extended_fcall_begin(TSRMLS_C); } @@ -1731,6 +1762,7 @@ if (!is_method && !is_dynamic_fcall && function_name->op_type==IS_CONST) { opline->opcode = ZEND_DO_FCALL; opline->op1 = *function_name; + ZVAL_LONG(&opline->op2.u.constant, zend_hash_func(Z_STRVAL(function_name->u.constant), Z_STRLEN(function_name->u.constant) + 1)); } else { opline->opcode = ZEND_DO_FCALL_BY_NAME; SET_UNUSED(opline->op1); @@ -3654,6 +3686,7 @@ opline->op1.op_type = IS_CONST; opline->extended_value = 1; SET_UNUSED(opline->op2); + ZVAL_LONG(&opline->op2.u.constant, zend_hash_func("shell_exec", sizeof("shell_exec"))); *result = opline->result; } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.48.2.22&r2=1.59.2.29.2.48.2.23&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.22 ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.23 --- ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.22 Wed Nov 21 12:28:13 2007 +++ ZendEngine2/zend_vm_def.h Thu Nov 22 09:02:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.22 2007/11/21 12:28:13 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.23 2007/11/22 09:02:54 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -1876,60 +1876,65 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (OP2_TYPE == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (OP2_TYPE != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (OP2_TYPE == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (OP2_TYPE != IS_CONST) { FREE_OP2(); } EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); +} + - EX(fbc) = function; +ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST) +{ + zend_op *opline = EX(opline); + zend_op *op_data = opline + 1; + ZEND_VM_INC_OPCODE(); + zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc))==FAILURE) { + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(op_data->op1.u.constant), Z_STRLEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==FAILURE || + EX(fbc)->type != ZEND_INTERNAL_FUNCTION) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL(opline->op2.u.constant)); + } + } + + EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -2134,7 +2139,7 @@ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { + if (zend_hash_quick_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, Z_LVAL(opline->op2.u.constant), (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", fname->value.str.val); } EX(object) = NULL; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.49.2.21&r2=1.62.2.30.2.49.2.22&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.21 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.22 --- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.21 Wed Nov 21 12:28:13 2007 +++ ZendEngine2/zend_vm_execute.h Thu Nov 22 09:02:54 2007 @@ -648,60 +648,65 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = &opline->op2.u.constant; if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_CONST != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (IS_CONST == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_CONST != IS_CONST) { } EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); +} + + +static int ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + zend_op *opline = EX(opline); + zend_op *op_data = opline + 1; - EX(fbc) = function; + ZEND_VM_INC_OPCODE(); + zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc))==FAILURE) { + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(op_data->op1.u.constant), Z_STRLEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==FAILURE || + EX(fbc)->type != ZEND_INTERNAL_FUNCTION) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL(opline->op2.u.constant)); + } + } + EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -807,60 +812,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_TMP_VAR == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_TMP_VAR != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - - if (IS_TMP_VAR == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_TMP_VAR != IS_CONST) { zval_dtor(free_op2.var); } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -923,60 +913,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_VAR != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (IS_VAR == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_VAR != IS_CONST) { if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -1067,60 +1042,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CV == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_CV != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - - if (IS_CV == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_CV != IS_CONST) { } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -1420,7 +1380,7 @@ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { + if (zend_hash_quick_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, Z_LVAL(opline->op2.u.constant), (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", fname->value.str.val); } EX(object) = NULL; @@ -29742,27 +29702,27 @@ ZEND_NEW_SPEC_HANDLER, ZEND_NEW_SPEC_HANDLER, ZEND_NEW_SPEC_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_opcodes.h?r1=1.42.2.17.2.1.2.2&r2=1.42.2.17.2.1.2.3&diff_format=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.2 ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.3 --- ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.2 Wed Nov 21 09:41:35 2007 +++ ZendEngine2/zend_vm_opcodes.h Thu Nov 22 09:02:55 2007 @@ -87,6 +87,7 @@ #define ZEND_SEND_VAR 66 #define ZEND_SEND_REF 67 #define ZEND_NEW 68 +#define ZEND_INIT_NS_FCALL_BY_NAME 69 #define ZEND_FREE 70 #define ZEND_INIT_ARRAY 71 #define ZEND_ADD_ARRAY_ELEMENT 72
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.23&r2=1.647.2.27.2.41.2.24&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.23 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.24 --- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.23 Wed Nov 21 09:41:33 2007 +++ ZendEngine2/zend_compile.c Thu Nov 22 09:02:53 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.23 2007/11/21 09:41:33 johannes Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.24 2007/11/22 09:02:53 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1446,8 +1446,16 @@ zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_INIT_FCALL_BY_NAME; opline->op2 = *left_bracket; - opline->extended_value = 0; - SET_UNUSED(opline->op1); + if (opline->op2.op_type == IS_CONST) { + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + } else { + opline->extended_value = 0; + SET_UNUSED(opline->op1); + } } zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); @@ -1474,19 +1482,42 @@ zend_op *opline; opline = get_next_op(CG(active_op_array) TSRMLS_CC); - opline->opcode = ZEND_INIT_FCALL_BY_NAME; - opline->op2 = *function_name; - opline->extended_value = 0; if (prefix_len) { /* In run-time PHP will check for function with full name and internal function with short name */ + opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME; + opline->op2 = *function_name; + opline->extended_value = 0; opline->op1.op_type = IS_CONST; - ZVAL_LONG(&opline->op1.u.constant, prefix_len); + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_OP_DATA; + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(function_name->u.constant) - prefix_len; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(function_name->u.constant) + prefix_len, Z_STRLEN(opline->op1.u.constant)); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); } else { - SET_UNUSED(opline->op1); + opline->opcode = ZEND_INIT_FCALL_BY_NAME; + opline->op2 = *function_name; + if (opline->op2.op_type == IS_CONST) { + opline->op1.op_type = IS_CONST; + Z_TYPE(opline->op1.u.constant) = IS_STRING; + Z_STRVAL(opline->op1.u.constant) = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant)); + Z_STRLEN(opline->op1.u.constant) = Z_STRLEN(opline->op2.u.constant); + opline->extended_value = zend_hash_func(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant) + 1); + } else { + opline->extended_value = 0; + SET_UNUSED(opline->op1); + } } + + zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); zend_do_extended_fcall_begin(TSRMLS_C); } @@ -1731,6 +1762,7 @@ if (!is_method && !is_dynamic_fcall && function_name->op_type==IS_CONST) { opline->opcode = ZEND_DO_FCALL; opline->op1 = *function_name; + ZVAL_LONG(&opline->op2.u.constant, zend_hash_func(Z_STRVAL(function_name->u.constant), Z_STRLEN(function_name->u.constant) + 1)); } else { opline->opcode = ZEND_DO_FCALL_BY_NAME; SET_UNUSED(opline->op1); @@ -3654,6 +3686,7 @@ opline->op1.op_type = IS_CONST; opline->extended_value = 1; SET_UNUSED(opline->op2); + ZVAL_LONG(&opline->op2.u.constant, zend_hash_func("shell_exec", sizeof("shell_exec"))); *result = opline->result; } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.48.2.22&r2=1.59.2.29.2.48.2.23&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.22 ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.23 --- ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.22 Wed Nov 21 12:28:13 2007 +++ ZendEngine2/zend_vm_def.h Thu Nov 22 09:02:54 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.22 2007/11/21 12:28:13 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.23 2007/11/22 09:02:54 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -1876,60 +1876,65 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (OP2_TYPE == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (OP2_TYPE != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (OP2_TYPE == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (OP2_TYPE != IS_CONST) { FREE_OP2(); } EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); +} + - EX(fbc) = function; +ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST) +{ + zend_op *opline = EX(opline); + zend_op *op_data = opline + 1; + ZEND_VM_INC_OPCODE(); + zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc))==FAILURE) { + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(op_data->op1.u.constant), Z_STRLEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==FAILURE || + EX(fbc)->type != ZEND_INTERNAL_FUNCTION) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL(opline->op2.u.constant)); + } + } + + EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -2134,7 +2139,7 @@ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { + if (zend_hash_quick_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, Z_LVAL(opline->op2.u.constant), (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", fname->value.str.val); } EX(object) = NULL; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.49.2.21&r2=1.62.2.30.2.49.2.22&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.21 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.22 --- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.21 Wed Nov 21 12:28:13 2007 +++ ZendEngine2/zend_vm_execute.h Thu Nov 22 09:02:54 2007 @@ -648,60 +648,65 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = &opline->op2.u.constant; if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_CONST != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (IS_CONST == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_CONST != IS_CONST) { } EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); +} + + +static int ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + zend_op *opline = EX(opline); + zend_op *op_data = opline + 1; - EX(fbc) = function; + ZEND_VM_INC_OPCODE(); + zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc))==FAILURE) { + if (zend_hash_quick_find(EG(function_table), Z_STRVAL(op_data->op1.u.constant), Z_STRLEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==FAILURE || + EX(fbc)->type != ZEND_INTERNAL_FUNCTION) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL(opline->op2.u.constant)); + } + } + EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -807,60 +812,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_TMP_VAR == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_TMP_VAR != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - - if (IS_TMP_VAR == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_TMP_VAR != IS_CONST) { zval_dtor(free_op2.var); } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -923,60 +913,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_VAR != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { - - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - if (IS_VAR == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_VAR != IS_CONST) { if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -1067,60 +1042,45 @@ { zend_op *opline = EX(opline); zval *function_name; - zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; + int ret; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CV == IS_CONST) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; + function_name_strval = Z_STRVAL(opline->op2.u.constant); + ret = zend_hash_quick_find(EG(function_table), Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)+1, opline->extended_value, (void **) &EX(fbc)); } else { function_name = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - if (IS_CV != IS_CONST && - function_name_strval[0] == ':' && - function_name_strval[1] == ':') { + function_name_strval = Z_STRVAL_P(function_name); + function_name_strlen = Z_STRLEN_P(function_name); + if (function_name_strval[0] == ':' && + function_name_strval[1] == ':') { - function_name_strlen -= 2; - lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); - } else { - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - } - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - - if (IS_CV == IS_CONST && opline->op1.op_type == IS_CONST) { - function_name_strlen -= Z_LVAL(opline->op1.u.constant); - lcname = zend_str_tolower_dup(function_name_strval + Z_LVAL(opline->op1.u.constant), function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE || - function->type != ZEND_INTERNAL_FUNCTION) { - efree(lcname); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); - } + function_name_strlen -= 2; + lcname = zend_str_tolower_dup(function_name_strval + 2, function_name_strlen); } else { - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); + lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } + ret = zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)); + efree(lcname); + } + + if (ret == FAILURE) { + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } - efree(lcname); if (IS_CV != IS_CONST) { } EX(object) = NULL; - - EX(fbc) = function; - ZEND_VM_NEXT_OPCODE(); } @@ -1420,7 +1380,7 @@ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { + if (zend_hash_quick_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, Z_LVAL(opline->op2.u.constant), (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", fname->value.str.val); } EX(object) = NULL; @@ -29742,27 +29702,27 @@ ZEND_NEW_SPEC_HANDLER, ZEND_NEW_SPEC_HANDLER, ZEND_NEW_SPEC_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, + ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, ZEND_NULL_HANDLER, http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_opcodes.h?r1=1.42.2.17.2.1.2.2&r2=1.42.2.17.2.1.2.3&diff_format=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.2 ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.3 --- ZendEngine2/zend_vm_opcodes.h:1.42.2.17.2.1.2.2 Wed Nov 21 09:41:35 2007 +++ ZendEngine2/zend_vm_opcodes.h Thu Nov 22 09:02:55 2007 @@ -87,6 +87,7 @@ #define ZEND_SEND_VAR 66 #define ZEND_SEND_REF 67 #define ZEND_NEW 68 +#define ZEND_INIT_NS_FCALL_BY_NAME 69 #define ZEND_FREE 70 #define ZEND_INIT_ARRAY 71 #define ZEND_ADD_ARRAY_ELEMENT 72