diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/opcache/Optimizer/optimize_func_calls.c | 9 | ||||
-rw-r--r-- | ext/opcache/Optimizer/pass1_5.c | 4 | ||||
-rw-r--r-- | ext/opcache/zend_accelerator_util_funcs.c | 50 | ||||
-rw-r--r-- | ext/opcache/zend_persist.c | 29 | ||||
-rw-r--r-- | ext/opcache/zend_persist_calc.c | 25 | ||||
-rw-r--r-- | ext/standard/tests/array/array_keys_error.phpt | 2 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/bug41037.phpt | 9 | ||||
-rw-r--r-- | ext/standard/tests/serialize/serialization_arrays_002.phpt | 12 | ||||
-rw-r--r-- | ext/standard/tests/serialize/serialization_objects_013.phpt | 12 |
9 files changed, 97 insertions, 55 deletions
diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c index ead951ac73..853d4bd7f4 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -20,6 +20,11 @@ /* pass 4 * - optimize INIT_FCALL_BY_NAME to DO_FCALL */ + +#define ZEND_OP2_IS_CONST_STRING(opline) \ + (ZEND_OP2_TYPE(opline) == IS_CONST && \ + Z_TYPE(op_array->literals[(opline)->op2.constant]) == IS_STRING) + typedef struct _optimizer_call_info { zend_function *func; zend_op *opline; @@ -42,7 +47,7 @@ static void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx switch (opline->opcode) { case ZEND_INIT_FCALL_BY_NAME: case ZEND_INIT_NS_FCALL_BY_NAME: - if (ZEND_OP2_TYPE(opline) == IS_CONST) { + if (ZEND_OP2_IS_CONST_STRING(opline)) { zend_function *func; zval *function_name = &op_array->literals[opline->op2.constant + 1]; if ((func = zend_hash_find_ptr(&ctx->script->function_table, @@ -81,7 +86,7 @@ static void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx } else if (opline->extended_value == 0 && call_stack[call].opline && call_stack[call].opline->opcode == ZEND_INIT_FCALL_BY_NAME && - ZEND_OP2_TYPE(call_stack[call].opline) == IS_CONST) { + ZEND_OP2_IS_CONST_STRING(call_stack[call].opline)) { zend_op *fcall = call_stack[call].opline; diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index de09e89123..cae4d0445d 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -472,7 +472,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { zval t; ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(opline))); - replace_tmp_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC); + replace_var_by_const(op_array, opline + 1, ZEND_RESULT(opline).var, &t TSRMLS_CC); literal_dtor(&ZEND_OP1_LITERAL(opline)); MAKE_NOP(opline); } @@ -485,7 +485,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { break; } ZVAL_TRUE(&c); - replace_tmp_by_const(op_array, opline, tv, &c TSRMLS_CC); + replace_var_by_const(op_array, opline, tv, &c TSRMLS_CC); literal_dtor(&ZEND_OP1_LITERAL(opline)); MAKE_NOP(opline); } diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index dd5340e572..f8554776a3 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -305,28 +305,44 @@ static inline void zend_clone_zval(zval *src, int bind TSRMLS_DC) static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC) { - int i; - zend_ast *node; - - if (ast->kind == ZEND_CONST) { - node = emalloc(sizeof(zend_ast) + sizeof(zval)); - node->kind = ZEND_CONST; - node->children = 0; - ZVAL_COPY_VALUE(&node->u.val, &ast->u.val); - zend_clone_zval(&node->u.val, 0 TSRMLS_CC); + uint32_t i; + + if (ast->kind == ZEND_AST_ZVAL) { + zend_ast_zval *copy = emalloc(sizeof(zend_ast_zval)); + copy->kind = ZEND_AST_ZVAL; + copy->attr = ast->attr; + ZVAL_COPY_VALUE(©->val, zend_ast_get_zval(ast)); + zend_clone_zval(©->val, 0 TSRMLS_CC); + return (zend_ast *) copy; + } else if (zend_ast_is_list(ast)) { + zend_ast_list *list = zend_ast_get_list(ast); + zend_ast_list *copy = emalloc( + sizeof(zend_ast_list) + sizeof(zend_ast *) * (list->children - 1)); + copy->kind = list->kind; + copy->attr = list->attr; + copy->children = list->children; + for (i = 0; i < list->children; i++) { + if (list->child[i]) { + copy->child[i] = zend_ast_clone(list->child[i] TSRMLS_CC); + } else { + copy->child[i] = NULL; + } + } + return (zend_ast *) copy; } else { - node = emalloc(sizeof(zend_ast) + sizeof(zend_ast*) * (ast->children - 1)); - node->kind = ast->kind; - node->children = ast->children; - for (i = 0; i < ast->children; i++) { - if ((&ast->u.child)[i]) { - (&node->u.child)[i] = zend_ast_clone((&ast->u.child)[i] TSRMLS_CC); + uint32_t children = zend_ast_get_num_children(ast); + zend_ast *copy = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1)); + copy->kind = ast->kind; + copy->attr = ast->attr; + for (i = 0; i < children; i++) { + if (ast->child[i]) { + copy->child[i] = zend_ast_clone(ast->child[i] TSRMLS_CC); } else { - (&node->u.child)[i] = NULL; + copy->child[i] = NULL; } } + return copy; } - return node; } static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind) diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 2427cfdec8..5e290745bd 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -144,20 +144,33 @@ static void zend_hash_persist_immutable(HashTable *ht TSRMLS_DC) static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC) { - int i; + uint32_t i; zend_ast *node; - if (ast->kind == ZEND_CONST) { - node = zend_accel_memdup(ast, sizeof(zend_ast)); - zend_persist_zval(&node->u.val TSRMLS_CC); + if (ast->kind == ZEND_AST_ZVAL) { + zend_ast_zval *copy = zend_accel_memdup(ast, sizeof(zend_ast_zval)); + zend_persist_zval(©->val TSRMLS_CC); + node = (zend_ast *) copy; + } else if (zend_ast_is_list(ast)) { + zend_ast_list *list = zend_ast_get_list(ast); + zend_ast_list *copy = zend_accel_memdup(ast, + sizeof(zend_ast_list) + sizeof(zend_ast *) * (list->children - 1)); + for (i = 0; i < list->children; i++) { + if (copy->child[i]) { + copy->child[i] = zend_persist_ast(copy->child[i] TSRMLS_CC); + } + } + node = (zend_ast *) copy; } else { - node = zend_accel_memdup(ast, sizeof(zend_ast) + sizeof(zend_ast*) * (ast->children - 1)); - for (i = 0; i < ast->children; i++) { - if ((&node->u.child)[i]) { - (&node->u.child)[i] = zend_persist_ast((&node->u.child)[i] TSRMLS_CC); + uint32_t children = zend_ast_get_num_children(ast); + node = zend_accel_memdup(ast, sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1)); + for (i = 0; i < children; i++) { + if (node->child[i]) { + node->child[i] = zend_persist_ast(node->child[i] TSRMLS_CC); } } } + efree(ast); return node; } diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 1328213397..989195119c 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -83,17 +83,26 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval * static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC) { - int i; + uint32_t i; START_SIZE(); - if (ast->kind == ZEND_CONST) { - ADD_SIZE(sizeof(zend_ast)); - ADD_SIZE(zend_persist_zval_calc(&ast->u.val TSRMLS_CC)); + if (ast->kind == ZEND_AST_ZVAL) { + ADD_SIZE(sizeof(zend_ast_zval)); + ADD_SIZE(zend_persist_zval_calc(zend_ast_get_zval(ast) TSRMLS_CC)); + } else if (zend_ast_is_list(ast)) { + zend_ast_list *list = zend_ast_get_list(ast); + ADD_SIZE(sizeof(zend_ast_list) + sizeof(zend_ast *) * (list->children - 1)); + for (i = 0; i < list->children; i++) { + if (list->child[i]) { + ADD_SIZE(zend_persist_ast_calc(list->child[i] TSRMLS_CC)); + } + } } else { - ADD_SIZE(sizeof(zend_ast) + sizeof(zend_ast*) * (ast->children - 1)); - for (i = 0; i < ast->children; i++) { - if ((&ast->u.child)[i]) { - ADD_SIZE(zend_persist_ast_calc((&ast->u.child)[i] TSRMLS_CC)); + uint32_t children = zend_ast_get_num_children(ast); + ADD_SIZE(sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1)); + for (i = 0; i < children; i++) { + if (ast->child[i]) { + ADD_SIZE(zend_persist_ast_calc(ast->child[i] TSRMLS_CC)); } } } diff --git a/ext/standard/tests/array/array_keys_error.phpt b/ext/standard/tests/array/array_keys_error.phpt index 316e91d7e6..685547f0ec 100644 --- a/ext/standard/tests/array/array_keys_error.phpt +++ b/ext/standard/tests/array/array_keys_error.phpt @@ -9,7 +9,7 @@ var_dump(array_keys("string")); var_dump(array_keys(new stdclass)); // object var_dump(array_keys()); // Zero arguments var_dump(array_keys(array(), "", TRUE, 100)); // args > expected -var_dump(array_keys(array(1,2,3, array() => array()))); // (W)illegal offset +var_dump(array_keys(array(1,2,3, new stdClass => array()))); // (W)illegal offset echo "Done\n"; ?> diff --git a/ext/standard/tests/general_functions/bug41037.phpt b/ext/standard/tests/general_functions/bug41037.phpt index eab2c334c9..0ffc8d58f6 100644 --- a/ext/standard/tests/general_functions/bug41037.phpt +++ b/ext/standard/tests/general_functions/bug41037.phpt @@ -8,10 +8,11 @@ function a() { unregister_tick_function('a'); } -declare (ticks=1); -register_tick_function('a'); +declare (ticks=1) { + register_tick_function('a'); -echo "Done\n"; + echo "Done\n"; +} ?> --EXPECTF-- hello @@ -19,5 +20,3 @@ Warning: unregister_tick_function(): Unable to delete tick function executed at Done hello Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d -hello -Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d diff --git a/ext/standard/tests/serialize/serialization_arrays_002.phpt b/ext/standard/tests/serialize/serialization_arrays_002.phpt index f8cef7818e..c62ff6a91c 100644 --- a/ext/standard/tests/serialize/serialization_arrays_002.phpt +++ b/ext/standard/tests/serialize/serialization_arrays_002.phpt @@ -37,16 +37,16 @@ check($a); echo "\n\n--- 0 refs 1:\n"; $a = array(); -$a[0] = &$a[1]; $a[1] = 1; +$a[0] = &$a[1]; $a[2] = 1; check($a); echo "\n\n--- 0 refs 2:\n"; $a = array(); +$a[2] = 1; $a[0] = &$a[2]; $a[1] = 1; -$a[2] = 1; check($a); echo "\n\n--- 1 refs 0:\n"; @@ -59,8 +59,8 @@ check($a); echo "\n\n--- 1 refs 2:\n"; $a = array(); $a[0] = 1; -$a[1] = &$a[2]; $a[2] = 1; +$a[1] = &$a[2]; check($a); echo "\n\n--- 2 refs 0:\n"; @@ -79,15 +79,15 @@ check($a); echo "\n\n--- 0,1 ref 2:\n"; $a = array(); +$a[2] = 1; $a[0] = &$a[2]; $a[1] = &$a[2]; -$a[2] = 1; check($a); echo "\n\n--- 0,2 ref 1:\n"; $a = array(); -$a[0] = &$a[1]; $a[1] = 1; +$a[0] = &$a[1]; $a[2] = &$a[1]; check($a); @@ -541,4 +541,4 @@ array(3) { [2]=> &string(10) "b2.changed" } -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/serialize/serialization_objects_013.phpt b/ext/standard/tests/serialize/serialization_objects_013.phpt index 01b623cb0d..403f9de08c 100644 --- a/ext/standard/tests/serialize/serialization_objects_013.phpt +++ b/ext/standard/tests/serialize/serialization_objects_013.phpt @@ -32,16 +32,16 @@ function check(&$obj) { echo "\n\n--- a refs b:\n"; $obj = new stdClass; -$obj->a = &$obj->b; $obj->b = 1; +$obj->a = &$obj->b; $obj->c = 1; check($obj); echo "\n\n--- a refs c:\n"; $obj = new stdClass; +$obj->c = 1; $obj->a = &$obj->c; $obj->b = 1; -$obj->c = 1; check($obj); echo "\n\n--- b refs a:\n"; @@ -54,8 +54,8 @@ check($obj); echo "\n\n--- b refs c:\n"; $obj = new stdClass; $obj->a = 1; -$obj->b = &$obj->c; $obj->c = 1; +$obj->b = &$obj->c; check($obj); echo "\n\n--- c refs a:\n"; @@ -74,15 +74,15 @@ check($obj); echo "\n\n--- a,b refs c:\n"; $obj = new stdClass; +$obj->c = 1; $obj->a = &$obj->c; $obj->b = &$obj->c; -$obj->c = 1; check($obj); echo "\n\n--- a,c refs b:\n"; $obj = new stdClass; -$obj->a = &$obj->b; $obj->b = 1; +$obj->a = &$obj->b; $obj->c = &$obj->b; check($obj); @@ -491,4 +491,4 @@ object(stdClass)#%d (3) { ["c"]=> &string(14) "obj->c.changed" } -Done
\ No newline at end of file +Done |