com php-src: Merge branch 'PHP-5.6': Zend/zend_compile.c
| From: | JulienPauli | Date: | Tue, 07 Jul 2015 13:03:58 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6': Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87784@lists.php.net to get a copy of this message | ||
Commit: dfb0c6363fd1a4bd75849e4637d7fd31dfc42857
Author: Julien Pauli <jpauli@php.net> Tue, 7 Jul 2015 15:03:58 +0200
Parents: 404dc93d35f7061fc4b1b41ad6cb0721b9b52bcc c22da81b71abe8c41a94fdea4e95a2bca8ec926d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dfb0c6363fd1a4bd75849e4637d7fd31dfc42857
Log:
Merge branch 'PHP-5.6'
* PHP-5.6:
Fixed double ZEND_TICKS opcode generation for declare()
Conflicts:
Zend/zend_compile.c
Changed paths:
MM Zend/zend_compile.c
Diff:
diff --cc Zend/zend_compile.c
index e655e84,278ac4e..3ae9567
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@@ -1854,39 -2117,75 +1854,44 @@@ static zend_op *zend_emit_op(znode *res
}
/* }}} */
-void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace, zend_bool
case_sensitive, HashTable *current_import_sub TSRMLS_DC) /* {{{ */
+static zend_op *zend_emit_op_tmp(znode *result, zend_uchar opcode, znode *op1, znode *op2) /* {{{
*/
{
- znode tmp;
- int len;
- zval **ns;
- char *lookup_name, *compound = memchr(Z_STRVAL(element_name->u.constant), '\\',
Z_STRLEN(element_name->u.constant));
+ zend_op *opline = get_next_op(CG(active_op_array));
+ opline->opcode = opcode;
- if (Z_STRVAL(element_name->u.constant)[0] == '\\') {
- /* name starts with \ so it is known and unambiguos, nothing to do here but shorten it */
- memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+1,
Z_STRLEN(element_name->u.constant));
- --Z_STRLEN(element_name->u.constant);
- return;
+ if (op1 == NULL) {
+ SET_UNUSED(opline->op1);
+ } else {
+ SET_NODE(opline->op1, op1);
}
- if(!*check_namespace) {
- return;
+ if (op2 == NULL) {
+ SET_UNUSED(opline->op2);
+ } else {
+ SET_NODE(opline->op2, op2);
}
- if (current_import_sub) {
- len = Z_STRLEN(element_name->u.constant)+1;
- if (case_sensitive) {
- lookup_name = estrndup(Z_STRVAL(element_name->u.constant), len);
- } else {
- lookup_name = zend_str_tolower_dup(Z_STRVAL(element_name->u..constant), len);
- }
- /* Check if function/const matches imported name */
- if (zend_hash_find(current_import_sub, lookup_name, len, (void**)&ns) == SUCCESS) {
- zval_dtor(&element_name->u.constant);
- element_name->u.constant = **ns;
- zval_copy_ctor(&element_name->u.constant);
- efree(lookup_name);
- *check_namespace = 0;
- return;
- }
- efree(lookup_name);
- }
-
- if (compound && CG(current_import)) {
- len = compound - Z_STRVAL(element_name->u.constant);
- /* namespace is always lowercase */
- lookup_name = zend_str_tolower_dup(Z_STRVAL(element_name->u.constant), len);
- /* Check if first part of compound name is an import name */
- if (zend_hash_find(CG(current_import), lookup_name, len+1, (void**)&ns) == SUCCESS) {
- /* Substitute import name */
- tmp.op_type = IS_CONST;
- tmp.u.constant = **ns;
- zval_copy_ctor(&tmp.u.constant);
- len += 1;
- Z_STRLEN(element_name->u.constant) -= len;
- memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+len,
Z_STRLEN(element_name->u.constant)+1);
- zend_do_build_namespace_name(&tmp, &tmp, element_name TSRMLS_CC);
- *element_name = tmp;
- efree(lookup_name);
- *check_namespace = 0;
- return;
- }
- efree(lookup_name);
+ if (result) {
+ zend_make_tmp_result(result, opline);
}
- if (CG(current_namespace)) {
- tmp = *element_name;
- Z_STRLEN(tmp.u.constant) = sizeof("\\")-1 + Z_STRLEN(element_name->u.constant) +
Z_STRLEN_P(CG(current_namespace));
- Z_STRVAL(tmp.u.constant) = (char *) emalloc(Z_STRLEN(tmp.u.constant)+1);
- memcpy(Z_STRVAL(tmp.u.constant), Z_STRVAL_P(CG(current_namespace)),
Z_STRLEN_P(CG(current_namespace)));
- memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN_P(CG(current_namespace))]), "\\",
sizeof("\\")-1);
- memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN_P(CG(current_namespace)) +
sizeof("\\")-1]), Z_STRVAL(element_name->u.constant),
Z_STRLEN(element_name->u.constant)+1);
- str_efree(Z_STRVAL(element_name->u.constant));
- *element_name = tmp;
+ return opline;
+}
+/* }}} */
+
+static void zend_emit_tick(void) /* {{{ */
+{
++ /* This prevents a double TICK generated by the parser statement of "declare()" */
++ if (CG(active_op_array)->last &&
CG(active_op_array)->opcodes[CG(active_op_array)->last - 1].opcode == ZEND_TICKS) {
++ return;
+ }
++
+ zend_op *opline = get_next_op(CG(active_op_array));
+
+ opline->opcode = ZEND_TICKS;
+ SET_UNUSED(opline->op1);
+ SET_UNUSED(opline->op2);
+ opline->extended_value = FC(declarables).ticks;
}
/* }}} */