diff options
author | Nikita Popov <nikic@php.net> | 2014-08-25 21:59:30 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2014-08-25 22:04:33 +0200 |
commit | 899a1ed59a2f7133367dc39f95b143c019822520 (patch) | |
tree | a8fc518673cf0c94ad363d04bc3474eb3f3bfa66 /ext/opcache/zend_persist.c | |
parent | af59e92b24c8f624672720d47ef65bd8457728b9 (diff) | |
parent | 6db293d5e043d35c281a6b11cb68460f5d7188a9 (diff) | |
download | php-git-POST_AST_MERGE.tar.gz |
Merge branch 'ast'POST_AST_MERGE
Conflicts:
Zend/zend_compile.c
Diffstat (limited to 'ext/opcache/zend_persist.c')
-rw-r--r-- | ext/opcache/zend_persist.c | 29 |
1 files changed, 21 insertions, 8 deletions
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; } |