Skip to content
Permalink
Browse files
Use better data structures (incomplete)
  • Loading branch information
dstogov committed Feb 10, 2014
1 parent 89a9ace commit f4cfaf36e23ca47da3e352e1c60909104c059647
Show file tree
Hide file tree
Showing 145 changed files with 21,295 additions and 23,809 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -1758,10 +1758,11 @@ static void zend_mm_safe_error(zend_mm_heap *heap,
uint error_lineno;
TSRMLS_FETCH();
if (zend_is_compiling(TSRMLS_C)) {
error_filename = zend_get_compiled_filename(TSRMLS_C);
zend_string *str = zend_get_compiled_filename(TSRMLS_C);
error_filename = str ? str->val : NULL;
error_lineno = zend_get_compiled_lineno(TSRMLS_C);
} else if (EG(in_execution)) {
error_filename = EG(active_op_array)?EG(active_op_array)->filename:NULL;
error_filename = EG(active_op_array)?EG(active_op_array)->filename->val:NULL;
error_lineno = EG(opline_ptr)?(*EG(opline_ptr))->lineno:0;
} else {
error_filename = NULL;
@@ -162,17 +162,10 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage TSRMLS_DC);
END_EXTERN_C()

/* fast cache for zval's */
#define ALLOC_ZVAL(z) \
(z) = (zval *) emalloc(sizeof(zval))

#define FREE_ZVAL(z) \
efree_rel(z)

#define ALLOC_ZVAL_REL(z) \
(z) = (zval *) emalloc_rel(sizeof(zval))

#define FREE_ZVAL_REL(z) \
efree_rel(z)
//???#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval))
//???#define FREE_ZVAL(z) efree_rel(z)
//???#define ALLOC_ZVAL_REL(z) (z) = (zval *) emalloc_rel(sizeof(zval))
//???#define FREE_ZVAL_REL(z) efree_rel(z)

/* fast cache for HashTables */
#define ALLOC_HASHTABLE(ht) \
@@ -28,8 +28,7 @@ ZEND_API zend_ast *zend_ast_create_constant(zval *zv)
zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zval));
ast->kind = ZEND_CONST;
ast->children = 0;
ast->u.val = (zval*)(ast + 1);
INIT_PZVAL_COPY(ast->u.val, zv);
ZVAL_COPY_VALUE(&ast->u.val, zv);
return ast;
}

@@ -68,7 +67,7 @@ ZEND_API int zend_ast_is_ct_constant(zend_ast *ast)
int i;

if (ast->kind == ZEND_CONST) {
return !IS_CONSTANT_TYPE(Z_TYPE_P(ast->u.val));
return !IS_CONSTANT_TYPE(Z_TYPE(ast->u.val));
} else {
for (i = 0; i < ast->children; i++) {
if ((&ast->u.child)[i]) {
@@ -223,10 +222,9 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
zval_dtor(&op2);
break;
case ZEND_CONST:
*result = *ast->u.val;
zval_copy_ctor(result);
ZVAL_DUP(result, &ast->u.val);
if (IS_CONSTANT_TYPE(Z_TYPE_P(result))) {
zval_update_constant_ex(&result, (void *) 1, scope TSRMLS_CC);
zval_update_constant_ex(result, (void *) 1, scope TSRMLS_CC);
}
break;
case ZEND_BOOL_AND:
@@ -287,8 +285,8 @@ ZEND_API zend_ast *zend_ast_copy(zend_ast *ast)
if (ast == NULL) {
return NULL;
} else if (ast->kind == ZEND_CONST) {
zend_ast *copy = zend_ast_create_constant(ast->u.val);
zval_copy_ctor(copy->u.val);
zend_ast *copy = zend_ast_create_constant(&ast->u.val);
zval_copy_ctor(&copy->u.val);
return copy;
} else {
switch (ast->children) {
@@ -317,7 +315,7 @@ ZEND_API void zend_ast_destroy(zend_ast *ast)
int i;

if (ast->kind == ZEND_CONST) {
zval_dtor(ast->u.val);
zval_dtor(&ast->u.val);
} else {
for (i = 0; i < ast->children; i++) {
if ((&ast->u.child)[i]) {
@@ -40,7 +40,7 @@ struct _zend_ast {
unsigned short kind;
unsigned short children;
union {
zval *val;
zval val;
zend_ast *child;
} u;
};

0 comments on commit f4cfaf3

Please sign in to comment.