cvs: ZendEngine2 / zend_compile.c zend_vm_def.h zend_vm_execute.h
| From: | Dmitry Stogov | Date: | Fri, 17 Aug 2007 12:05:19 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_vm_def.h zend_vm_execute.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5960@lists.php.net to get a copy of this message | ||
dmitry Fri Aug 17 12:05:19 2007 UTC
Modified files:
/ZendEngine2 zend_compile.c zend_vm_def.h zend_vm_execute.h
Log:
Namespaces: improved run-time speed
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.760&r2=1.761&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.760 ZendEngine2/zend_compile.c:1.761 --- ZendEngine2/zend_compile.c:1.760 Fri Jul 27 13:41:35 2007 +++ ZendEngine2/zend_compile.c Fri Aug 17 12:05:19 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.760 2007/07/27 13:41:35 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.761 2007/08/17 12:05:19 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1579,7 +1579,7 @@ } /* }}} */ -void zend_resolve_class_name(znode *class_name, ulong *fetch_type TSRMLS_DC) /* {{{ */ +void zend_resolve_class_name(znode *class_name, ulong *fetch_type, int check_ns_name TSRMLS_DC) /* {{{ */ { zstr compound; unsigned int lcname_len; @@ -1642,14 +1642,17 @@ zval_copy_ctor(&class_name->u.constant); } else if (CG(current_namespace)) { zend_class_entry **pce; - unsigned int ns_lcname_len; - zstr ns_lcname = zend_u_str_case_fold(Z_TYPE_P(CG(current_namespace)), Z_UNIVAL_P(CG(current_namespace)), Z_UNILEN_P(CG(current_namespace)), 0, &ns_lcname_len); - if (ns_lcname_len == lcname_len && - memcmp(lcname.v, ns_lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len) == 0) { - *fetch_type |= ZEND_FETCH_CLASS_RT_NS_NAME; + if (check_ns_name) { + unsigned int ns_lcname_len; + zstr ns_lcname = zend_u_str_case_fold(Z_TYPE_P(CG(current_namespace)), Z_UNIVAL_P(CG(current_namespace)), Z_UNILEN_P(CG(current_namespace)), 0, &ns_lcname_len); + + if (ns_lcname_len == lcname_len && + memcmp(lcname.v, ns_lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len) == 0) { + *fetch_type |= ZEND_FETCH_CLASS_RT_NS_NAME; + } + efree(ns_lcname.v); } - efree(ns_lcname.v); if (zend_u_hash_find(CG(class_table), Z_TYPE(class_name->u.constant), lcname, lcname_len+1, (void**)&pce) == SUCCESS && (*pce)->type == ZEND_INTERNAL_CLASS) { @@ -1690,7 +1693,7 @@ zval_dtor(&class_name->u.constant); break; default: { - zend_resolve_class_name(class_name, &opline->extended_value TSRMLS_CC); + zend_resolve_class_name(class_name, &opline->extended_value, 0 TSRMLS_CC); opline->op2 = *class_name; break; } @@ -1761,7 +1764,7 @@ method_name->op_type == IS_CONST && ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant), Z_UNILEN(class_name->u.constant))) { fetch_type = ZEND_FETCH_CLASS_GLOBAL; - zend_resolve_class_name(class_name, &fetch_type TSRMLS_CC); + zend_resolve_class_name(class_name, &fetch_type, 1 TSRMLS_CC); class_node = *class_name; } else { zend_do_fetch_class(&class_node, class_name TSRMLS_CC); @@ -1772,6 +1775,58 @@ opline->op1 = class_node; opline->op2 = *method_name; + if (class_node.op_type == IS_CONST && + method_name->op_type == IS_CONST) { + /* Prebuild ns::func name to speedup run-time check */ + zstr fname, lcname; + unsigned int len, lcname_len; + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_OP_DATA; + opline->op1.op_type = IS_CONST; + SET_UNUSED(opline->op2); + + len = Z_UNILEN(class_node.u.constant) + 2 + Z_UNILEN(method_name->u.constant); + if (UG(unicode)) { + fname.u = eumalloc(len + 1); + memcpy(fname.u, Z_USTRVAL(class_node.u.constant), UBYTES(Z_USTRLEN(class_node.u.constant))); + fname.u[Z_USTRLEN(class_node.u.constant)] = ':'; + fname.u[Z_USTRLEN(class_node.u.constant)+1] = ':'; + memcpy(fname.u+Z_USTRLEN(class_node.u.constant)+2, + Z_USTRVAL(method_name->u.constant), + UBYTES(Z_USTRLEN(method_name->u.constant)+1)); + lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); + opline->extended_value = zend_u_hash_func(IS_UNICODE, lcname, lcname_len + 1); + ZVAL_UNICODEL(&opline->op1.u.constant, lcname.u, lcname_len, 0); + } else { + fname.s = emalloc(len + 1); + memcpy(fname.s, Z_STRVAL(class_node.u.constant), Z_STRLEN(class_node.u.constant)); + fname.s[Z_STRLEN(class_node.u.constant)] = ':'; + fname.s[Z_STRLEN(class_node.u.constant)+1] = ':'; + memcpy(fname.s+Z_STRLEN(class_node.u.constant)+2, + Z_STRVAL(method_name->u.constant), + Z_STRLEN(method_name->u.constant)+1); + lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); + opline->extended_value = zend_u_hash_func(IS_STRING, lcname, lcname_len + 1); + ZVAL_STRINGL(&opline->op1.u.constant, lcname.s, lcname_len, 0); + } + efree(fname.v); + + if (fetch_type & ZEND_FETCH_CLASS_RT_NS_NAME) { + zstr colon; + + if (UG(unicode) && (colon.u = u_memchr(lcname.u, ':', lcname_len)) && colon.u[1] == ':') { + colon.u += 2; + opline->op2.op_type = IS_CONST; + ZVAL_UNICODEL(&opline->op2.u.constant, colon.u, lcname_len - (colon.u - lcname.u), 1); + } else if (!UG(unicode) && (colon.s = memchr(lcname.s, ':', lcname_len)) && colon.s[1] == ':') { + colon.s += 2; + opline->op2.op_type = IS_CONST; + ZVAL_STRINGL(&opline->op2.u.constant, colon.s, lcname_len - (colon.s - lcname.s), 1); + } + } + } + zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); zend_do_extended_fcall_begin(TSRMLS_C); } @@ -3658,7 +3713,7 @@ ulong fetch_type; if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_TYPE(constant_container->u.constant), Z_UNIVAL(constant_container->u.constant), Z_UNILEN(constant_container->u.constant))) { - zend_resolve_class_name(constant_container, &fetch_type TSRMLS_CC); + zend_resolve_class_name(constant_container, &fetch_type, 1 TSRMLS_CC); } zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.176&r2=1.177&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.176 ZendEngine2/zend_vm_def.h:1.177 --- ZendEngine2/zend_vm_def.h:1.176 Wed Aug 1 11:44:24 2007 +++ ZendEngine2/zend_vm_def.h Fri Aug 17 12:05:19 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.176 2007/08/01 11:44:24 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.177 2007/08/17 12:05:19 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -1793,33 +1793,11 @@ if (OP1_TYPE == IS_CONST && OP2_TYPE == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; - - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + zend_op *op_data = opline+1; - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + ZEND_VM_INC_OPCODE(); + + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -1828,34 +1806,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -1866,8 +1834,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.180&r2=1.181&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.180 ZendEngine2/zend_vm_execute.h:1.181 --- ZendEngine2/zend_vm_execute.h:1.180 Wed Aug 1 11:44:24 2007 +++ ZendEngine2/zend_vm_execute.h Fri Aug 17 12:05:19 2007 @@ -2545,33 +2545,11 @@ if (IS_CONST == IS_CONST && IS_CONST == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -2580,34 +2558,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -2618,8 +2586,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3050,33 +3016,11 @@ if (IS_CONST == IS_CONST && IS_TMP_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3085,34 +3029,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3123,8 +3057,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3556,33 +3488,11 @@ if (IS_CONST == IS_CONST && IS_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3591,34 +3501,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3629,8 +3529,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3828,33 +3726,11 @@ if (IS_CONST == IS_CONST && IS_UNUSED == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3863,34 +3739,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3901,8 +3767,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -4302,33 +4166,11 @@ if (IS_CONST == IS_CONST && IS_CV == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -4337,34 +4179,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -4375,8 +4207,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -10208,33 +10038,11 @@ if (IS_VAR == IS_CONST && IS_CONST == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -10243,34 +10051,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -10281,8 +10079,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -11945,33 +11741,11 @@ if (IS_VAR == IS_CONST && IS_TMP_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -11980,34 +11754,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -12018,8 +11782,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -13674,33 +13436,11 @@ if (IS_VAR == IS_CONST && IS_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -13709,34 +13449,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -13747,8 +13477,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -14601,33 +14329,11 @@ if (IS_VAR == IS_CONST && IS_UNUSED == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -14636,34 +14342,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -14674,8 +14370,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -15980,33 +15674,11 @@ if (IS_VAR == IS_CONST && IS_CV == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -16015,34 +15687,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -16053,8 +15715,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; }
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.760&r2=1.761&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.760 ZendEngine2/zend_compile.c:1.761 --- ZendEngine2/zend_compile.c:1.760 Fri Jul 27 13:41:35 2007 +++ ZendEngine2/zend_compile.c Fri Aug 17 12:05:19 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.760 2007/07/27 13:41:35 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.761 2007/08/17 12:05:19 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1579,7 +1579,7 @@ } /* }}} */ -void zend_resolve_class_name(znode *class_name, ulong *fetch_type TSRMLS_DC) /* {{{ */ +void zend_resolve_class_name(znode *class_name, ulong *fetch_type, int check_ns_name TSRMLS_DC) /* {{{ */ { zstr compound; unsigned int lcname_len; @@ -1642,14 +1642,17 @@ zval_copy_ctor(&class_name->u.constant); } else if (CG(current_namespace)) { zend_class_entry **pce; - unsigned int ns_lcname_len; - zstr ns_lcname = zend_u_str_case_fold(Z_TYPE_P(CG(current_namespace)), Z_UNIVAL_P(CG(current_namespace)), Z_UNILEN_P(CG(current_namespace)), 0, &ns_lcname_len); - if (ns_lcname_len == lcname_len && - memcmp(lcname.v, ns_lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len) == 0) { - *fetch_type |= ZEND_FETCH_CLASS_RT_NS_NAME; + if (check_ns_name) { + unsigned int ns_lcname_len; + zstr ns_lcname = zend_u_str_case_fold(Z_TYPE_P(CG(current_namespace)), Z_UNIVAL_P(CG(current_namespace)), Z_UNILEN_P(CG(current_namespace)), 0, &ns_lcname_len); + + if (ns_lcname_len == lcname_len && + memcmp(lcname.v, ns_lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len) == 0) { + *fetch_type |= ZEND_FETCH_CLASS_RT_NS_NAME; + } + efree(ns_lcname.v); } - efree(ns_lcname.v); if (zend_u_hash_find(CG(class_table), Z_TYPE(class_name->u.constant), lcname, lcname_len+1, (void**)&pce) == SUCCESS && (*pce)->type == ZEND_INTERNAL_CLASS) { @@ -1690,7 +1693,7 @@ zval_dtor(&class_name->u.constant); break; default: { - zend_resolve_class_name(class_name, &opline->extended_value TSRMLS_CC); + zend_resolve_class_name(class_name, &opline->extended_value, 0 TSRMLS_CC); opline->op2 = *class_name; break; } @@ -1761,7 +1764,7 @@ method_name->op_type == IS_CONST && ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant), Z_UNILEN(class_name->u.constant))) { fetch_type = ZEND_FETCH_CLASS_GLOBAL; - zend_resolve_class_name(class_name, &fetch_type TSRMLS_CC); + zend_resolve_class_name(class_name, &fetch_type, 1 TSRMLS_CC); class_node = *class_name; } else { zend_do_fetch_class(&class_node, class_name TSRMLS_CC); @@ -1772,6 +1775,58 @@ opline->op1 = class_node; opline->op2 = *method_name; + if (class_node.op_type == IS_CONST && + method_name->op_type == IS_CONST) { + /* Prebuild ns::func name to speedup run-time check */ + zstr fname, lcname; + unsigned int len, lcname_len; + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_OP_DATA; + opline->op1.op_type = IS_CONST; + SET_UNUSED(opline->op2); + + len = Z_UNILEN(class_node.u.constant) + 2 + Z_UNILEN(method_name->u.constant); + if (UG(unicode)) { + fname.u = eumalloc(len + 1); + memcpy(fname.u, Z_USTRVAL(class_node.u.constant), UBYTES(Z_USTRLEN(class_node.u.constant))); + fname.u[Z_USTRLEN(class_node.u.constant)] = ':'; + fname.u[Z_USTRLEN(class_node.u.constant)+1] = ':'; + memcpy(fname.u+Z_USTRLEN(class_node.u.constant)+2, + Z_USTRVAL(method_name->u.constant), + UBYTES(Z_USTRLEN(method_name->u.constant)+1)); + lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); + opline->extended_value = zend_u_hash_func(IS_UNICODE, lcname, lcname_len + 1); + ZVAL_UNICODEL(&opline->op1.u.constant, lcname.u, lcname_len, 0); + } else { + fname.s = emalloc(len + 1); + memcpy(fname.s, Z_STRVAL(class_node.u.constant), Z_STRLEN(class_node.u.constant)); + fname.s[Z_STRLEN(class_node.u.constant)] = ':'; + fname.s[Z_STRLEN(class_node.u.constant)+1] = ':'; + memcpy(fname.s+Z_STRLEN(class_node.u.constant)+2, + Z_STRVAL(method_name->u.constant), + Z_STRLEN(method_name->u.constant)+1); + lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); + opline->extended_value = zend_u_hash_func(IS_STRING, lcname, lcname_len + 1); + ZVAL_STRINGL(&opline->op1.u.constant, lcname.s, lcname_len, 0); + } + efree(fname.v); + + if (fetch_type & ZEND_FETCH_CLASS_RT_NS_NAME) { + zstr colon; + + if (UG(unicode) && (colon.u = u_memchr(lcname.u, ':', lcname_len)) && colon.u[1] == ':') { + colon.u += 2; + opline->op2.op_type = IS_CONST; + ZVAL_UNICODEL(&opline->op2.u.constant, colon.u, lcname_len - (colon.u - lcname.u), 1); + } else if (!UG(unicode) && (colon.s = memchr(lcname.s, ':', lcname_len)) && colon.s[1] == ':') { + colon.s += 2; + opline->op2.op_type = IS_CONST; + ZVAL_STRINGL(&opline->op2.u.constant, colon.s, lcname_len - (colon.s - lcname.s), 1); + } + } + } + zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); zend_do_extended_fcall_begin(TSRMLS_C); } @@ -3658,7 +3713,7 @@ ulong fetch_type; if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_TYPE(constant_container->u.constant), Z_UNIVAL(constant_container->u.constant), Z_UNILEN(constant_container->u.constant))) { - zend_resolve_class_name(constant_container, &fetch_type TSRMLS_CC); + zend_resolve_class_name(constant_container, &fetch_type, 1 TSRMLS_CC); } zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.176&r2=1.177&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.176 ZendEngine2/zend_vm_def.h:1.177 --- ZendEngine2/zend_vm_def.h:1.176 Wed Aug 1 11:44:24 2007 +++ ZendEngine2/zend_vm_def.h Fri Aug 17 12:05:19 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.176 2007/08/01 11:44:24 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.177 2007/08/17 12:05:19 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -1793,33 +1793,11 @@ if (OP1_TYPE == IS_CONST && OP2_TYPE == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; - - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + zend_op *op_data = opline+1; - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + ZEND_VM_INC_OPCODE(); + + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -1828,34 +1806,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -1866,8 +1834,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.180&r2=1.181&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.180 ZendEngine2/zend_vm_execute.h:1.181 --- ZendEngine2/zend_vm_execute.h:1.180 Wed Aug 1 11:44:24 2007 +++ ZendEngine2/zend_vm_execute.h Fri Aug 17 12:05:19 2007 @@ -2545,33 +2545,11 @@ if (IS_CONST == IS_CONST && IS_CONST == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -2580,34 +2558,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -2618,8 +2586,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3050,33 +3016,11 @@ if (IS_CONST == IS_CONST && IS_TMP_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3085,34 +3029,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3123,8 +3057,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3556,33 +3488,11 @@ if (IS_CONST == IS_CONST && IS_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3591,34 +3501,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3629,8 +3529,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -3828,33 +3726,11 @@ if (IS_CONST == IS_CONST && IS_UNUSED == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -3863,34 +3739,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -3901,8 +3767,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -4302,33 +4166,11 @@ if (IS_CONST == IS_CONST && IS_CV == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -4337,34 +4179,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -4375,8 +4207,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -10208,33 +10038,11 @@ if (IS_VAR == IS_CONST && IS_CONST == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -10243,34 +10051,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -10281,8 +10079,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -11945,33 +11741,11 @@ if (IS_VAR == IS_CONST && IS_TMP_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -11980,34 +11754,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -12018,8 +11782,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -13674,33 +13436,11 @@ if (IS_VAR == IS_CONST && IS_VAR == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -13709,34 +13449,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -13747,8 +13477,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -14601,33 +14329,11 @@ if (IS_VAR == IS_CONST && IS_UNUSED == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -14636,34 +14342,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -14674,8 +14370,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; } @@ -15980,33 +15674,11 @@ if (IS_VAR == IS_CONST && IS_CV == IS_CONST) { /* try a function in namespace */ - zstr fname, lcname; - unsigned int len, lcname_len; + zend_op *op_data = opline+1; - len = Z_UNILEN(opline->op1.u.constant) + 2 + Z_UNILEN(opline->op2.u.constant); - if (UG(unicode)) { - fname.u = eumalloc(len + 1); - memcpy(fname.u, Z_USTRVAL(opline->op1.u.constant), UBYTES(Z_USTRLEN(opline->op1.u.constant))); - fname.u[Z_USTRLEN(opline->op1.u.constant)] = ':'; - fname.u[Z_USTRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.u+Z_USTRLEN(opline->op1.u.constant)+2, - Z_USTRVAL(opline->op2.u.constant), - UBYTES(Z_USTRLEN(opline->op2.u.constant)+1)); - lcname = zend_u_str_case_fold(IS_UNICODE, fname, len, 1, &lcname_len); - } else { - fname.s = emalloc(len + 1); - memcpy(fname.s, Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant)); - fname.s[Z_STRLEN(opline->op1.u.constant)] = ':'; - fname.s[Z_STRLEN(opline->op1.u.constant)+1] = ':'; - memcpy(fname.s+Z_STRLEN(opline->op1.u.constant)+2, - Z_STRVAL(opline->op2.u.constant), - Z_STRLEN(opline->op2.u.constant)+1); - lcname = zend_u_str_case_fold(IS_STRING, fname, len, 1, &lcname_len); - } - efree(fname.v); + ZEND_VM_INC_OPCODE(); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, lcname, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); + if (zend_u_hash_quick_find(EG(function_table), Z_TYPE(op_data->op1.u.constant), Z_UNIVAL(op_data->op1.u.constant), Z_UNILEN(op_data->op1.u.constant)+1, op_data->extended_value, (void **) &EX(fbc))==SUCCESS) { EX(object) = NULL; ZEND_VM_NEXT_OPCODE(); } @@ -16015,34 +15687,24 @@ ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) ? (opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK) : opline->extended_value TSRMLS_CC); if (!ce) { - if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) { - zstr ns; + if ((opline->extended_value & ZEND_FETCH_CLASS_RT_NS_NAME) && + op_data->op2.op_type == IS_CONST) { - if (UG(unicode) && (ns.u = u_memchr(lcname.u, ':', lcname_len)) && ns.u[1] == ':') { - ns.u += 2; - lcname_len -= (ns.u - lcname.u); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } - } else if (!UG(unicode) && (ns.s = memchr(lcname.s, ':', lcname_len)) && ns.s[1] == ':') { - ns.s += 2; - lcname_len -= (ns.s - lcname.s); - if (zend_u_hash_find(EG(function_table), ZEND_STR_TYPE, ns, lcname_len+1, (void **) &EX(fbc))==SUCCESS) { - efree(lcname.v); - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); - } + if (zend_u_hash_find(EG(function_table), Z_TYPE(op_data->op2.u.constant), Z_UNIVAL(op_data->op2.u.constant), Z_UNILEN(op_data->op2.u.constant) + 1, (void **) &EX(fbc))==SUCCESS) { + EX(object) = NULL; + ZEND_VM_NEXT_OPCODE(); } + if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) { - lcname_len -= Z_UNILEN(opline->op2.u.constant) + 2; + zstr ce_name; + unsigned ce_name_len = Z_UNILEN(op_data->op1.u.constant) - (Z_UNILEN(op_data->op2.u.constant) + 2); if (UG(unicode)) { - ns.u[lcname_len] = 0; + ce_name.u = eustrndup(Z_USTRVAL(op_data->op1.u.constant), ce_name_len); } else { - ns.s[lcname_len] = 0; + ce_name.s = estrndup(Z_STRVAL(op_data->op1.u.constant), ce_name_len); } - ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ns, lcname_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + ce = zend_u_fetch_class(Z_TYPE(opline->op1.u.constant), ce_name, ce_name_len, opline->extended_value & ~ZEND_FETCH_CLASS_RT_NS_CHECK TSRMLS_CC); + efree(ce_name.v); if (!ce) { zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } @@ -16053,8 +15715,6 @@ zend_error(E_ERROR, "Class '%R' not found", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); } } - - efree(lcname.v); } else { ce = EX_T(opline->op1.u.var).class_entry; }