mirror of
https://github.com/php/php-src.git
synced 2026-04-24 08:28:26 +02:00
Update opcache for new AST structures
This commit is contained in:
@@ -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;
|
||||
zend_uint i;
|
||||
|
||||
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);
|
||||
} 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);
|
||||
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 {
|
||||
(&node->u.child)[i] = NULL;
|
||||
copy->child[i] = NULL;
|
||||
}
|
||||
}
|
||||
return (zend_ast *) copy;
|
||||
} else {
|
||||
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 {
|
||||
copy->child[i] = NULL;
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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(©->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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user