Get rid of AiCount completely

This commit is contained in:
Zeev Suraski 1999-07-10 11:45:23 +00:00
parent 82563bde60
commit cccd2445ee
7 changed files with 22 additions and 80 deletions

View file

@ -398,16 +398,6 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
t = t->pNext; 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
} }

View file

@ -1561,7 +1561,7 @@ void do_list_end(znode *result, znode *expr CLS_DC)
if (le == CG(list_llist).tail) { if (le == CG(list_llist).tail) {
opline->extended_value = ZEND_FETCH_STANDARD; opline->extended_value = ZEND_FETCH_STANDARD;
} else { } else {
opline->extended_value = ZEND_FETCH_NO_AI_COUNT; opline->extended_value = ZEND_FETCH_ADD_LOCK;
} }
last_container = opline->result; last_container = opline->result;
dimension = dimension->next; dimension = dimension->next;

View file

@ -539,7 +539,7 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_DECLARE_INHERITED_CLASS 3 #define ZEND_DECLARE_INHERITED_CLASS 3
#define ZEND_FETCH_STANDARD 0 #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_MEMBER_FUNC_CALL 1<<0
#define ZEND_CTOR_CALL 1<<1 #define ZEND_CTOR_CALL 1<<1

View 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 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) #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; break;
case IS_VAR: case IS_VAR:
if (Ts[node->u.var].var) { if (Ts[node->u.var].var) {
DEC_AI_COUNT();
PZVAL_UNLOCK(*Ts[node->u.var].var); PZVAL_UNLOCK(*Ts[node->u.var].var);
*should_free = 0; *should_free = 0;
return *Ts[node->u.var].var; 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) { switch(node->op_type) {
case IS_VAR: case IS_VAR:
if (Ts[node->u.var].var) { if (Ts[node->u.var].var) {
DEC_AI_COUNT();
PZVAL_UNLOCK(*Ts[node->u.var].var); PZVAL_UNLOCK(*Ts[node->u.var].var);
} }
return 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; break;
} }
Ts[result->u.var].var = &EG(uninitialized_zval_ptr); Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
return; 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 (variable_ptr == EG(error_zval_ptr)) {
if (result) { if (result) {
Ts[result->u.var].var = &EG(uninitialized_zval_ptr); Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
} }
return; return;
} }
@ -346,7 +340,6 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
} }
if (result) { if (result) {
Ts[result->u.var].var = variable_ptr_ptr; Ts[result->u.var].var = variable_ptr_ptr;
INC_AI_COUNT(result);
SELECTIVE_PZVAL_LOCK(*variable_ptr_ptr, 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: case ZEND_FETCH_GLOBAL:
if (op1->op_type == IS_VAR) { if (op1->op_type == IS_VAR) {
PZVAL_LOCK(varname); PZVAL_LOCK(varname);
EG(AiCount)++;
} }
target_symbol_table = &EG(symbol_table); target_symbol_table = &EG(symbol_table);
break; break;
@ -448,7 +440,6 @@ static inline void zend_fetch_var_address(znode *result, znode *op1, znode *op2,
zval_dtor(varname); zval_dtor(varname);
} }
Ts[result->u.var].var = retval; Ts[result->u.var].var = retval;
INC_AI_COUNT(result);
SELECTIVE_PZVAL_LOCK(*retval, 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; container = *container_ptr;
if (container == EG(error_zval_ptr)) { if (container == EG(error_zval_ptr)) {
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
*retval = &EG(error_zval_ptr); *retval = &EG(error_zval_ptr);
return; return;
} }
@ -652,8 +642,7 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode
} }
break; break;
} }
INC_AI_COUNT(result); /* Had INC_AI_COUNT - Relevant cases handled above */
/* 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); zval *container = get_zval_ptr(op1, Ts, &free_op1, BP_VAR_R);
if (container->type != IS_ARRAY) { if (container->type != IS_ARRAY) {
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
Ts[result->u.var].var = &EG(uninitialized_zval_ptr); Ts[result->u.var].var = &EG(uninitialized_zval_ptr);
return; 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); 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); 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; container = *container_ptr;
if (container == EG(error_zval_ptr)) { if (container == EG(error_zval_ptr)) {
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
*retval = &EG(error_zval_ptr); *retval = &EG(error_zval_ptr);
return; 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); offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R);
FREE_OP(op2, free_op2); FREE_OP(op2, free_op2);
INC_AI_COUNT(result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
if (type==BP_VAR_R || type==BP_VAR_IS) { if (type==BP_VAR_R || type==BP_VAR_IS) {
*retval = &EG(uninitialized_zval_ptr); *retval = &EG(uninitialized_zval_ptr);
return; return;
@ -790,7 +775,6 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
zendi_zval_copy_ctor(*container); zendi_zval_copy_ctor(*container);
} }
*retval = zend_fetch_property_address_inner(container->value.obj.properties, op2, Ts, type ELS_CC); *retval = zend_fetch_property_address_inner(container->value.obj.properties, op2, Ts, type ELS_CC);
INC_AI_COUNT(result);
SELECTIVE_PZVAL_LOCK(**retval, result); SELECTIVE_PZVAL_LOCK(**retval, result);
} }
@ -999,8 +983,7 @@ binary_assign_op_addr: {
} }
if (*var_ptr == EG(error_zval_ptr)) { if (*var_ptr == EG(error_zval_ptr)) {
Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr); Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr);
INC_AI_COUNT(&opline->result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
opline++; opline++;
continue; 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)); binary_op(*var_ptr, *var_ptr, get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R));
(*var_ptr)->EA.locks = previous_lock_count; (*var_ptr)->EA.locks = previous_lock_count;
Ts[opline->result.u.var].var = var_ptr; Ts[opline->result.u.var].var = var_ptr;
INC_AI_COUNT(&opline->result);
SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result); SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result);
FREE_OP(&opline->op2, free_op2); FREE_OP(&opline->op2, free_op2);
} }
@ -1038,8 +1020,7 @@ binary_assign_op_addr: {
} }
if (*var_ptr == EG(error_zval_ptr)) { if (*var_ptr == EG(error_zval_ptr)) {
Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr); Ts[opline->result.u.var].var = &EG(uninitialized_zval_ptr);
INC_AI_COUNT(&opline->result); /* Had INC_AI_COUNT: No need to lock anything */
/* No need to lock anything */
opline++; opline++;
continue; continue;
} }
@ -1071,7 +1052,6 @@ binary_assign_op_addr: {
case ZEND_PRE_INC: case ZEND_PRE_INC:
case ZEND_PRE_DEC: case ZEND_PRE_DEC:
Ts[opline->result.u.var].var = var_ptr; Ts[opline->result.u.var].var = var_ptr;
INC_AI_COUNT(&opline->result);
SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result); SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result);
break; 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); zend_fetch_var_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_IS ELS_CC);
break; break;
case ZEND_FETCH_DIM_R: 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); 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); zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC);
break; break;
@ -1140,8 +1119,7 @@ binary_assign_op_addr: {
break; break;
case ZEND_ASSIGN_REF: 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); 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); /* Had INC_AI_COUNT: Handled inside zend_assign_to_variable_reference() now */
/* Handled inside zend_assign_to_variable_reference() now */
break; break;
case ZEND_JMP: case ZEND_JMP:
#if DEBUG_ZEND>=2 #if DEBUG_ZEND>=2
@ -1290,11 +1268,9 @@ binary_assign_op_addr: {
if (opline->extended_value & ZEND_CTOR_CALL) { if (opline->extended_value & ZEND_CTOR_CALL) {
/* constructor call */ /* constructor call */
EG(AiCount)++; /* for op1 */
PZVAL_LOCK(*Ts[opline->op1.u.var].var); PZVAL_LOCK(*Ts[opline->op1.u.var].var);
if (opline->op2.op_type==IS_VAR) { if (opline->op2.op_type==IS_VAR) {
PZVAL_LOCK(*Ts[opline->op2.u.var].var); PZVAL_LOCK(*Ts[opline->op2.u.var].var);
EG(AiCount)++;
} }
} }
function_name = get_zval_ptr(&opline->op2, Ts, &free_op2, BP_VAR_R); 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) { 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()); zend_error(E_NOTICE, "Missing argument %d for %s()\n", opline->op1.u.constant.value.lval, get_active_function_name());
DEC_AI_COUNT(); if (opline->result.op_type == IS_VAR) {
/* No need to unlock anything, I think */ PZVAL_UNLOCK(*Ts[opline->result.u.var].var);
}
} else if (PZVAL_IS_REF(*param)) { } 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); zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, Ts, BP_VAR_W), param, NULL ELS_CC);
} else { } 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 (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param ELS_CC)==FAILURE) {
if (opline->op2.op_type == IS_UNUSED) { if (opline->op2.op_type == IS_UNUSED) {
DEC_AI_COUNT(); if (opline->result.op_type == IS_VAR) {
/* No need to unlock anything, I think */ PZVAL_UNLOCK(*Ts[opline->result.u.var].var);
}
break; break;
} }
if (opline->op2.u.constant.type == IS_CONSTANT) { if (opline->op2.u.constant.type == IS_CONSTANT) {
@ -1618,7 +1596,6 @@ send_by_ref:
case ZEND_CASE: case ZEND_CASE:
if (opline->op1.op_type == IS_VAR) { if (opline->op1.op_type == IS_VAR) {
PZVAL_LOCK(*Ts[opline->op1.u.var].var); PZVAL_LOCK(*Ts[opline->op1.u.var].var);
EG(AiCount)++;
} }
is_equal_function(&Ts[opline->result.u.var].tmp_var, is_equal_function(&Ts[opline->result.u.var].tmp_var,
get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R), get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R),
@ -1875,7 +1852,6 @@ send_by_ref:
case ZEND_JMP_NO_CTOR: { case ZEND_JMP_NO_CTOR: {
zval *object; zval *object;
EG(AiCount)++;
PZVAL_LOCK(*Ts[opline->op1.u.var].var); PZVAL_LOCK(*Ts[opline->op1.u.var].var);
object = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); object = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R);
if (!object->value.obj.ce->handle_function_call if (!object->value.obj.ce->handle_function_call

View file

@ -102,7 +102,6 @@ void init_executor(CLS_D ELS_DC)
zend_ptr_stack_init(&EG(argument_stack)); zend_ptr_stack_init(&EG(argument_stack));
EG(AiCount) = 0;
zend_ptr_stack_init(&EG(garbage)); zend_ptr_stack_init(&EG(garbage));
EG(main_op_array) = NULL; EG(main_op_array) = NULL;

View file

@ -196,8 +196,6 @@ struct _zend_executor_globals {
long precision; long precision;
unsigned int AiCount;
zend_ptr_stack garbage; zend_ptr_stack garbage;
/* for extended information support */ /* for extended information support */

View file

@ -61,35 +61,14 @@ ZEND_API int zval_dtor(zval *zvalue)
ELS_FETCH(); ELS_FETCH();
if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) { 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); zend_hash_destroy(zvalue->value.ht);
efree(zvalue->value.ht); efree(zvalue->value.ht);
#endif
} }
} }
break; break;
case IS_OBJECT: { case IS_OBJECT:
#ifdef USE_AI_COUNT zend_hash_destroy(zvalue->value.obj.properties);
ELS_FETCH(); efree(zvalue->value.obj.properties);
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
}
break; break;
case IS_RESOURCE: case IS_RESOURCE:
/* destroy resource */ /* destroy resource */