From cccd2445ee690c1e954af0189e40a20f34ddb0f9 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sat, 10 Jul 1999 11:45:23 +0000 Subject: [PATCH] Get rid of AiCount completely --- Zend/zend_alloc.c | 10 ------- Zend/zend_compile.c | 2 +- Zend/zend_compile.h | 2 +- Zend/zend_execute.c | 58 ++++++++++++----------------------------- Zend/zend_execute_API.c | 1 - Zend/zend_globals.h | 2 -- Zend/zend_variables.c | 27 +++---------------- 7 files changed, 22 insertions(+), 80 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2b12a5312b..52cb641b98 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -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 } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 619bb8cc1b..9db844daa0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 1ed2b1b644..16fc9d8e37 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -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 diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index bab7fe5766..bbee78b98b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -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 **) ¶m 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 **) ¶m 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 diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index d7c9affcc2..7f7f292a8f 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -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; diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index e679d00054..cba0f45358 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -196,8 +196,6 @@ struct _zend_executor_globals { long precision; - unsigned int AiCount; - zend_ptr_stack garbage; /* for extended information support */ diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 49c9c53df3..b0f399ccd0 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -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 */ -- 2.40.0