From: Nikita Popov Date: Thu, 19 Jun 2014 11:08:21 +0000 (+0200) Subject: Make ast->children a uint X-Git-Tag: POST_AST_MERGE^2~198 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89ecd73a0402a4a0f6bfcf579177b8b3e91b4dc6;p=php Make ast->children a uint Future optimization: only use uint for dynamic lists and use a uchar or even an introspection function to get the child count. --- diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index ba0b57fccc..9a795599fe 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -27,7 +27,7 @@ ZEND_API zend_ast *zend_ast_create_constant(zval *zv) { zend_ast_zval *ast = emalloc(sizeof(zend_ast_zval)); ast->kind = ZEND_CONST; - ast->children = 0; + ast->EA = 0; ZVAL_COPY_VALUE(&ast->val, zv); return (zend_ast *) ast; } @@ -36,7 +36,7 @@ ZEND_API zend_ast *zend_ast_create_znode(znode *node) { zend_ast_znode *ast = emalloc(sizeof(zend_ast_znode)); ast->kind = ZEND_AST_ZNODE; - ast->children = 0; + ast->EA = 0; ast->node = *node; return (zend_ast *) ast; } @@ -45,6 +45,7 @@ ZEND_API zend_ast* zend_ast_create_unary(uint kind, zend_ast *op0) { zend_ast *ast = emalloc(sizeof(zend_ast)); ast->kind = kind; + ast->EA = 0; ast->children = 1; ast->child[0] = op0; return ast; @@ -54,6 +55,7 @@ ZEND_API zend_ast* zend_ast_create_binary(uint kind, zend_ast *op0, zend_ast *op { zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *)); ast->kind = kind; + ast->EA = 0; ast->children = 2; ast->child[0] = op0; ast->child[1] = op1; @@ -64,6 +66,7 @@ ZEND_API zend_ast* zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *o { zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * 2); ast->kind = kind; + ast->EA = 0; ast->children = 3; ast->child[0] = op0; ast->child[1] = op1; @@ -76,6 +79,7 @@ ZEND_API zend_ast *zend_ast_create_dynamic(uint kind) /* use 4 children as default */ zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * 3); ast->kind = kind; + ast->EA = 0; ast->children = 0; return ast; } @@ -396,7 +400,7 @@ ZEND_API void zend_ast_destroy(zend_ast *ast) if (ast->kind == ZEND_CONST) { zval_dtor(zend_ast_get_zval(ast)); - } else { + } else if (ast->kind != ZEND_AST_ZNODE) { for (i = 0; i < ast->children; i++) { if (ast->child[i]) { zend_ast_destroy(ast->child[i]); diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index c89b82c84e..cceb3b0f8f 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -75,13 +75,14 @@ typedef enum _zend_ast_kind { struct _zend_ast { unsigned short kind; - unsigned short children; + unsigned short EA; + zend_uint children; zend_ast *child[1]; }; typedef struct _zend_ast_zval { unsigned short kind; - unsigned short children; + unsigned short EA; zval val; } zend_ast_zval; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index bbf2bc7274..6dfa74f023 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -90,7 +90,7 @@ typedef struct _znode { /* used only during compilation */ /* Temporarily defined here, to avoid header ordering issues */ typedef struct _zend_ast_znode { unsigned short kind; - unsigned short children; + unsigned short EA; znode node; } zend_ast_znode; ZEND_API zend_ast *zend_ast_create_znode(znode *node);