]> granicus.if.org Git - php/commitdiff
Get rid of AiCount completely
authorZeev Suraski <zeev@php.net>
Sat, 10 Jul 1999 11:45:23 +0000 (11:45 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 10 Jul 1999 11:45:23 +0000 (11:45 +0000)
Zend/zend_alloc.c
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_variables.c

index 2b12a5312baed69f6387cefc6d893bd9d4e06597..52cb641b98e7fa0d8106101b2e90e49ca4e5b8ec 100644 (file)
@@ -398,16 +398,6 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
                        t = t->pNext;
                }
        }
-
-#ifdef ZEND_DEBUG
-       if (had_leaks) {
-               ELS_FETCH();
-
-               if (EG(AiCount)!=0 && !silent) {
-                       fprintf(stderr, "AiCount did not zero out:  %d\n", EG(AiCount));
-               }
-       }
-#endif
 }
 
 
index 619bb8cc1bf4cc72e74f4448cacc947fea876633..9db844daa08db7537fd5f0e7daf1badee6557645 100644 (file)
@@ -1561,7 +1561,7 @@ void do_list_end(znode *result, znode *expr CLS_DC)
                        if (le == CG(list_llist).tail) {
                                opline->extended_value = ZEND_FETCH_STANDARD;
                        } else {
-                               opline->extended_value = ZEND_FETCH_NO_AI_COUNT;
+                               opline->extended_value = ZEND_FETCH_ADD_LOCK;
                        }
                        last_container = opline->result;
                        dimension = dimension->next;
index 1ed2b1b6449025811c0d15455eda70b76623cd24..16fc9d8e376e557fb73e95c5f1ea2f20287e9570 100644 (file)
@@ -539,7 +539,7 @@ int zendlex(znode *zendlval CLS_DC);
 #define ZEND_DECLARE_INHERITED_CLASS   3
 
 #define ZEND_FETCH_STANDARD            0
-#define ZEND_FETCH_NO_AI_COUNT 1
+#define ZEND_FETCH_ADD_LOCK            1
 
 #define ZEND_MEMBER_FUNC_CALL  1<<0
 #define ZEND_CTOR_CALL                 1<<1
index bab7fe5766de7f81f123f54301da06dccad417d4..bbee78b98bf9be4e7da8d8cc11377ebd696eb217 100644 (file)
@@ -35,8 +35,6 @@ static void destroy_garbage(HashTable *ht)
 }
 
 
-#define INC_AI_COUNT(znode_ptr)                if (!((znode_ptr)->u.EA.type & EXT_TYPE_UNUSED)) { EG(AiCount)++; }
-#define DEC_AI_COUNT()         if (--EG(AiCount)==0) { zend_ptr_stack_clean(&EG(garbage), (void (*)(void *)) destroy_garbage); }
 #define SELECTIVE_PZVAL_LOCK(pzv, pzn)         if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }
 
 #define get_zval_ptr(node, Ts, should_free, type) _get_zval_ptr(node, Ts, should_free ELS_CC)
@@ -86,7 +84,6 @@ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, int *should_fr
                        break;
                case IS_VAR:
                        if (Ts[node->u.var].var) {
-                               DEC_AI_COUNT();
                                PZVAL_UNLOCK(*Ts[node->u.var].var);
                                *should_free = 0;
                                return *Ts[node->u.var].var;
@@ -144,7 +141,6 @@ static inline zval **_get_zval_ptr_ptr(znode *node, temp_variable *Ts ELS_DC)
        switch(node->op_type) {
                case IS_VAR:
                        if (Ts[node->u.var].var) {
-                               DEC_AI_COUNT();
                                PZVAL_UNLOCK(*Ts[node->u.var].var);
                        }
                        return Ts[node->u.var].var;
@@ -256,8 +252,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
                                break;
                }
                Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
-               INC_AI_COUNT(result);
-               /* No need to lock anything */
+               /* Had INC_AI_COUNT:  No need to lock anything */
                return;
        }
 
@@ -266,8 +261,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
        if (variable_ptr == EG(error_zval_ptr)) {
                if (result) {
                        Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
-                       INC_AI_COUNT(result);
-                       /* No need to lock anything */
+                       /* Had INC_AI_COUNT:  No need to lock anything */
                }
                return;
        }
@@ -346,7 +340,6 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
        }
        if (result) {
                Ts[result->u.var].var = variable_ptr_ptr;
-               INC_AI_COUNT(result);
                SELECTIVE_PZVAL_LOCK(*variable_ptr_ptr, result);
        } 
 }
@@ -399,7 +392,6 @@ static inline void zend_fetch_var_address(znode *result, znode *op1, znode *op2,
                case ZEND_FETCH_GLOBAL:
                        if (op1->op_type == IS_VAR) {
                                PZVAL_LOCK(varname);
-                               EG(AiCount)++;
                        }
                        target_symbol_table = &EG(symbol_table);
                        break;
@@ -448,7 +440,6 @@ static inline void zend_fetch_var_address(znode *result, znode *op1, znode *op2,
                zval_dtor(varname);
        }
        Ts[result->u.var].var = retval; 
-       INC_AI_COUNT(result);
        SELECTIVE_PZVAL_LOCK(*retval, result);
 }
 
@@ -568,8 +559,7 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode
        container = *container_ptr;
 
        if (container == EG(error_zval_ptr)) {
-               INC_AI_COUNT(result);
-               /* No need to lock anything */
+               /* Had INC_AI_COUNT:  No need to lock anything */
                *retval = &EG(error_zval_ptr);
                return;
        }
@@ -652,8 +642,7 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode
                        }
                        break;
        }
-       INC_AI_COUNT(result);
-       /* Relevant cases handled above */
+       /* Had INC_AI_COUNT - Relevant cases handled above */
 }
 
 
@@ -663,13 +652,11 @@ static inline void zend_fetch_dimension_address_from_tmp_var(znode *result, znod
        zval *container = get_zval_ptr(op1, Ts, &free_op1, BP_VAR_R);
 
        if (container->type != IS_ARRAY) {
-               INC_AI_COUNT(result);
-               /* No need to lock anything */
+               /* Had INC_AI_COUNT:  No need to lock anything */
                Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
                return;
        }
 
-       INC_AI_COUNT(result);
        Ts[result->u.var].var = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, BP_VAR_R ELS_CC);
        SELECTIVE_PZVAL_LOCK(*Ts[result->u.var].var, result);
 }
@@ -718,8 +705,7 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
 
        container = *container_ptr;
        if (container == EG(error_zval_ptr)) {
-               INC_AI_COUNT(result);
-               /* No need to lock anything */
+               /* Had INC_AI_COUNT:  No need to lock anything */
                *retval = &EG(error_zval_ptr);
                return;
        }
@@ -769,8 +755,7 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
 
                offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R);
                FREE_OP(op2, free_op2);
-               INC_AI_COUNT(result);
-               /* No need to lock anything */
+               /* Had INC_AI_COUNT:  No need to lock anything */
                if (type==BP_VAR_R || type==BP_VAR_IS) {
                        *retval = &EG(uninitialized_zval_ptr);
                        return;
@@ -790,7 +775,6 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
                zendi_zval_copy_ctor(*container);
        }
        *retval = zend_fetch_property_address_inner(container->value.obj.properties, op2, Ts, type ELS_CC);
-       INC_AI_COUNT(result);
        SELECTIVE_PZVAL_LOCK(**retval, result);
 }
 
@@ -999,8 +983,7 @@ binary_assign_op_addr: {
                                        }
                                        if (*var_ptr == EG(error_zval_ptr)) {
                                                Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr);
-                                               INC_AI_COUNT(&opline->result);
-                                               /* No need to lock anything */
+                                               /* Had INC_AI_COUNT:  No need to lock anything */
                                                opline++;
                                                continue;
                                        }
@@ -1020,7 +1003,6 @@ binary_assign_op_addr: {
                                        binary_op(*var_ptr, *var_ptr, get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R));
                                        (*var_ptr)->EA.locks = previous_lock_count;
                                        Ts[opline->result.u.var].var = var_ptr;
-                                       INC_AI_COUNT(&opline->result);
                                        SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result);
                                        FREE_OP(&opline->op2, free_op2);
                                }
@@ -1038,8 +1020,7 @@ binary_assign_op_addr: {
                                        }
                                        if (*var_ptr == EG(error_zval_ptr)) {
                                                Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr);
-                                               INC_AI_COUNT(&opline->result);
-                                               /* No need to lock anything */
+                                               /* Had INC_AI_COUNT:  No need to lock anything */
                                                opline++;
                                                continue;
                                        }
@@ -1071,7 +1052,6 @@ binary_assign_op_addr: {
                                                case ZEND_PRE_INC:
                                                case ZEND_PRE_DEC:
                                                        Ts[opline->result.u.var].var = var_ptr;
-                                                       INC_AI_COUNT(&opline->result);
                                                        SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result);
                                                        break;
                                        }
@@ -1101,9 +1081,8 @@ binary_assign_op_addr: {
                                zend_fetch_var_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_IS ELS_CC);
                                break;
                        case ZEND_FETCH_DIM_R:
-                               if (opline->extended_value == ZEND_FETCH_NO_AI_COUNT) {
+                               if (opline->extended_value == ZEND_FETCH_ADD_LOCK) {
                                        PZVAL_LOCK(*Ts[opline->op1.u.var].var);
-                                       EG(AiCount)++;
                                }
                                zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
                                break;
@@ -1140,8 +1119,7 @@ binary_assign_op_addr: {
                                break;
                        case ZEND_ASSIGN_REF:
                                zend_assign_to_variable_reference(&opline->result, get_zval_ptr_ptr(&opline->op1, Ts, BP_VAR_W), get_zval_ptr_ptr(&opline->op2, Ts, BP_VAR_W), Ts ELS_CC);
-                               INC_AI_COUNT(&opline->result);
-                               /* Handled inside zend_assign_to_variable_reference() now */
+                               /* Had INC_AI_COUNT:  Handled inside zend_assign_to_variable_reference() now */
                                break;
                        case ZEND_JMP:
 #if DEBUG_ZEND>=2
@@ -1290,11 +1268,9 @@ binary_assign_op_addr: {
 
                                        if (opline->extended_value & ZEND_CTOR_CALL) {
                                                /* constructor call */
-                                               EG(AiCount)++; /* for op1 */
                                                PZVAL_LOCK(*Ts[opline->op1.u.var].var);
                                                if (opline->op2.op_type==IS_VAR) {
                                                        PZVAL_LOCK(*Ts[opline->op2.u.var].var);
-                                                       EG(AiCount)++;
                                                }
                                        }
                                        function_name = get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R);
@@ -1526,8 +1502,9 @@ send_by_ref:
 
                                        if (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param ELS_CC)==FAILURE) {
                                                zend_error(E_NOTICE, "Missing argument %d for %s()\n", opline->op1.u.constant.value.lval, get_active_function_name());
-                                               DEC_AI_COUNT();
-                                               /* No need to unlock anything, I think */
+                                               if (opline->result.op_type == IS_VAR) {
+                                                       PZVAL_UNLOCK(*Ts[opline->result.u.var].var);
+                                               }
                                        } else if (PZVAL_IS_REF(*param)) {
                                                zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, Ts, BP_VAR_W), param, NULL ELS_CC);
                                        } else {
@@ -1540,8 +1517,9 @@ send_by_ref:
 
                                        if (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param ELS_CC)==FAILURE) {
                                                if (opline->op2.op_type == IS_UNUSED) {
-                                                       DEC_AI_COUNT();
-                                                       /* No need to unlock anything, I think */
+                                                       if (opline->result.op_type == IS_VAR) {
+                                                               PZVAL_UNLOCK(*Ts[opline->result.u.var].var);
+                                                       }
                                                        break;
                                                }
                                                if (opline->op2.u.constant.type == IS_CONSTANT) {
@@ -1618,7 +1596,6 @@ send_by_ref:
                        case ZEND_CASE:
                                if (opline->op1.op_type == IS_VAR) {
                                        PZVAL_LOCK(*Ts[opline->op1.u.var].var);
-                                       EG(AiCount)++;
                                }
                                is_equal_function(&Ts[opline->result.u.var].tmp_var, 
                                                         get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R),
@@ -1875,7 +1852,6 @@ send_by_ref:
                        case ZEND_JMP_NO_CTOR: {
                                        zval *object;
 
-                                       EG(AiCount)++;
                                        PZVAL_LOCK(*Ts[opline->op1.u.var].var);
                                        object = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
                                        if (!object->value.obj.ce->handle_function_call
index d7c9affcc26c315dc8fa561e48bc8e7d0363f00f..7f7f292a8f1f00f07c92a2ab6667b03d498bc8b3 100644 (file)
@@ -102,7 +102,6 @@ void init_executor(CLS_D ELS_DC)
 
        zend_ptr_stack_init(&EG(argument_stack));
 
-       EG(AiCount) = 0;
        zend_ptr_stack_init(&EG(garbage));
 
        EG(main_op_array) = NULL;
index e679d000546551dbe3aa41b81505863451097ea9..cba0f4535870ded00268f5d9e0100e5201061ca4 100644 (file)
@@ -196,8 +196,6 @@ struct _zend_executor_globals {
 
        long precision;
 
-       unsigned int AiCount;
-
        zend_ptr_stack garbage;
 
        /* for extended information support */
index 49c9c53df37c251164f8bc80522712c55ac1b9d6..b0f399ccd00c60533ebca96bb07bf4a6d52dc250 100644 (file)
@@ -61,35 +61,14 @@ ZEND_API int zval_dtor(zval *zvalue)
                                ELS_FETCH();
 
                                if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
-#ifdef USE_AI_COUNT
-                                       if (EG(AiCount)==0) {
-                                               zend_hash_destroy(zvalue->value.ht);
-                                               efree(zvalue->value.ht);
-                                       } else {
-                                               zend_ptr_stack_push(&EG(garbage), zvalue->value.ht);
-                                       }
-#else
                                        zend_hash_destroy(zvalue->value.ht);
                                        efree(zvalue->value.ht);
-#endif
                                }
                        }
                        break;
-               case IS_OBJECT: {
-#ifdef USE_AI_COUNT
-                       ELS_FETCH();
-
-                               if (EG(AiCount)==0) {
-                                       zend_hash_destroy(zvalue->value.obj.properties);
-                                       efree(zvalue->value.obj.properties);
-                               } else {
-                                       zend_ptr_stack_push(&EG(garbage), zvalue->value.obj.properties);
-                               }
-#else
-                               zend_hash_destroy(zvalue->value.obj.properties);
-                               efree(zvalue->value.obj.properties);
-#endif
-                       }
+               case IS_OBJECT:
+                       zend_hash_destroy(zvalue->value.obj.properties);
+                       efree(zvalue->value.obj.properties);
                        break;
                case IS_RESOURCE:
                        /* destroy resource */