summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-08-15 22:02:53 +0200
committerNikita Popov <nikic@php.net>2014-08-15 22:02:53 +0200
commitfbef2af2c3ac756015d7a8d8bd46dc3096652bbe (patch)
tree73846740ad516f03cf5851e70bfe944ce7ba7997 /ext
parente607215e47e9138f17fc236d6f02db4f585f9120 (diff)
downloadphp-git-fbef2af2c3ac756015d7a8d8bd46dc3096652bbe.tar.gz
Update opcache for new AST structures
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c50
-rw-r--r--ext/opcache/zend_persist.c29
-rw-r--r--ext/opcache/zend_persist_calc.c25
3 files changed, 71 insertions, 33 deletions
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index ad5f44baa0..0c3b808c63 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -326,28 +326,44 @@ static inline void zend_clone_zval(zval *src, int bind TSRMLS_DC)
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
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);
+ zend_uint 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(&copy->val, zend_ast_get_zval(ast));
+ zend_clone_zval(&copy->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);
+ zend_uint 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;
}
#endif
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index e47cfda894..a01b00e874 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -139,20 +139,33 @@ static void zend_hash_persist_immutable(HashTable *ht TSRMLS_DC)
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC)
{
- int i;
+ zend_uint 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(&copy->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) + 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);
+ zend_uint 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 b6740db044..dc7f96727c 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -88,17 +88,26 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *
#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
{
- int i;
+ zend_uint 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));
+ zend_uint 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));
}
}
}