Permalink
Browse files

- Hooray. This might actually work. (I hope)

  • Loading branch information...
1 parent f114050 commit 1c0f1364057691741ec316c7389b23f177a7a9c7 @andigutmans andigutmans committed Oct 3, 1999
Showing with 23 additions and 5 deletions.
  1. +15 −1 Zend/zend_compile.h
  2. +0 −2 Zend/zend_execute.c
  3. +5 −1 Zend/zend_execute_API.c
  4. +3 −1 Zend/zend_globals.h
View
@@ -568,7 +568,21 @@ int zendlex(znode *zendlval CLS_DC);
#define PZVAL_IS_REF(z) ((z)->is_ref)
#define PZVAL_LOCK(z) ((z)->refcount++)
-#define PZVAL_UNLOCK(z) ((z)->refcount--)
+#define PZVAL_UNLOCK(z) { ((z)->refcount--); \
+ if (!(z)->refcount) { \
+ EG(garbage)[EG(garbage_ptr)++] = (z); \
+ if (EG(garbage_ptr) == 4) { \
+ zval_dtor(EG(garbage)[0]); \
+ efree(EG(garbage)[0]); \
+ zval_dtor(EG(garbage)[1]); \
+ efree(EG(garbage)[1]); \
+ EG(garbage)[0] = EG(garbage)[2]; \
+ EG(garbage)[1] = EG(garbage)[3]; \
+ EG(garbage_ptr) -= 2; \
+ } \
+ } \
+ }
+
#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }
#endif /* _COMPILE_H */
View
@@ -1508,15 +1508,13 @@ binary_assign_op_addr: {
EG(opline_ptr) = &opline;
EG(active_op_array) = op_array;
EG(return_value)=original_return_value;
- EG(destroying_function_symbol_table) = 1;
if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) {
zend_hash_destroy(function_state.function_symbol_table);
efree(function_state.function_symbol_table);
} else {
*(++EG(symtable_cache_ptr)) = function_state.function_symbol_table;
zend_hash_clean(*EG(symtable_cache_ptr));
}
- EG(destroying_function_symbol_table) = 0;
EG(active_symbol_table) = calling_symbol_table;
} else { /* ZEND_OVERLOADED_FUNCTION */
call_overloaded_function(opline->extended_value, &Ts[opline->result.u.var].tmp_var, &EG(regular_list), &EG(persistent_list) ELS_CC);
View
@@ -89,7 +89,6 @@ void init_executor(CLS_D ELS_DC)
EG(error_zval).refcount = 1;
EG(error_zval).is_ref=0;
EG(error_zval_ptr)=&EG(error_zval);
- EG(destroying_function_symbol_table) = 0;
zend_ptr_stack_init(&EG(arg_types_stack));
zend_stack_init(&EG(overloaded_objects_stack));
/* destroys stack frame, therefore makes core dumps worthless */
@@ -115,6 +114,7 @@ void init_executor(CLS_D ELS_DC)
zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_activator);
EG(opline_ptr) = NULL;
+ EG(garbage_ptr) = 0;
}
@@ -144,6 +144,10 @@ void shutdown_executor(ELS_D)
#if ZEND_DEBUG
signal(SIGSEGV, original_sigsegv_handler);
#endif
+ while (EG(garbage_ptr)--) {
+ zval_dtor(EG(garbage)[EG(garbage_ptr)]);
+ efree(EG(garbage)[EG(garbage_ptr)]);
+ }
}
View
@@ -138,7 +138,6 @@ struct _zend_executor_globals {
HashTable *zend_constants; /* constants table */
long precision;
- zend_bool destroying_function_symbol_table;
/* for extended information support */
zend_bool no_extensions;
@@ -151,6 +150,9 @@ struct _zend_executor_globals {
int (*unary_op)(zval *result, zval *op1);
int (*binary_op)(zval *result, zval *op1, zval *op2);
+ zval *garbage[4];
+ int garbage_ptr;
+
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
#if SUPPORT_INTERACTIVE
int interactive;

0 comments on commit 1c0f136

Please sign in to comment.