Diff for /embedaddon/php/Zend/zend_execute_API.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:47:52 version 1.1.1.2, 2012/05/29 12:34:35
Line 110  static int clean_non_persistent_function(zend_function Line 110  static int clean_non_persistent_function(zend_function
   
 static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */  static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
 {  {
        return (function->type != ZEND_INTERNAL_FUNCTION);        return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
 }  }
 /* }}} */  /* }}} */
   
Line 122  static int clean_non_persistent_class(zend_class_entry Line 122  static int clean_non_persistent_class(zend_class_entry
   
 static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */  static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
 {  {
        return ((*ce)->type != ZEND_INTERNAL_CLASS);        return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
 }  }
 /* }}} */  /* }}} */
   
Line 159  void init_executor(TSRMLS_D) /* {{{ */ Line 159  void init_executor(TSRMLS_D) /* {{{ */
         zend_vm_stack_push((void *) NULL TSRMLS_CC);          zend_vm_stack_push((void *) NULL TSRMLS_CC);
   
         zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);          zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);
         {  
                 zval *globals;  
   
                 ALLOC_ZVAL(globals);  
                 Z_SET_REFCOUNT_P(globals, 1);  
                 Z_SET_ISREF_P(globals);  
                 Z_TYPE_P(globals) = IS_ARRAY;  
                 Z_ARRVAL_P(globals) = &EG(symbol_table);  
                 zend_hash_update(&EG(symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL);  
         }  
         EG(active_symbol_table) = &EG(symbol_table);          EG(active_symbol_table) = &EG(symbol_table);
   
         zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);          zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);
Line 204  void init_executor(TSRMLS_D) /* {{{ */ Line 194  void init_executor(TSRMLS_D) /* {{{ */
         EG(active_op_array) = NULL;          EG(active_op_array) = NULL;
   
         EG(active) = 1;          EG(active) = 1;
           EG(start_op) = NULL;
 }  }
 /* }}} */  /* }}} */
   
Line 292  void shutdown_executor(TSRMLS_D) /* {{{ */ Line 283  void shutdown_executor(TSRMLS_D) /* {{{ */
                  * not contain objects and thus are not probelmatic */                   * not contain objects and thus are not probelmatic */
                 if (EG(full_tables_cleanup)) {                  if (EG(full_tables_cleanup)) {
                         zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);                          zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
                           zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC);
                 } else {                  } else {
                         zend_hash_reverse_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);                          zend_hash_reverse_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
                           zend_hash_reverse_apply(EG(class_table), (apply_func_t) zend_cleanup_user_class_data TSRMLS_CC);
                           zend_cleanup_internal_classes(TSRMLS_C);
                 }                  }
                 zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC);  
         } zend_end_try();          } zend_end_try();
   
         zend_try {          zend_try {
Line 305  void shutdown_executor(TSRMLS_D) /* {{{ */ Line 298  void shutdown_executor(TSRMLS_D) /* {{{ */
   
                 /* Destroy all op arrays */                  /* Destroy all op arrays */
                 if (EG(full_tables_cleanup)) {                  if (EG(full_tables_cleanup)) {
                        zend_hash_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);                        zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
                        zend_hash_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);                        zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
                 } else {                  } else {
                         zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function TSRMLS_CC);                          zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function TSRMLS_CC);
                         zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class TSRMLS_CC);                          zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class TSRMLS_CC);
Line 348  void shutdown_executor(TSRMLS_D) /* {{{ */ Line 341  void shutdown_executor(TSRMLS_D) /* {{{ */
 /* }}} */  /* }}} */
   
 /* return class name and "::" or "". */  /* return class name and "::" or "". */
ZEND_API char *get_active_class_name(char **space TSRMLS_DC) /* {{{ */ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC) /* {{{ */
 {  {
         if (!zend_is_executing(TSRMLS_C)) {          if (!zend_is_executing(TSRMLS_C)) {
                 if (space) {                  if (space) {
Line 376  ZEND_API char *get_active_class_name(char **space TSRM Line 369  ZEND_API char *get_active_class_name(char **space TSRM
 }  }
 /* }}} */  /* }}} */
   
ZEND_API char *get_active_function_name(TSRMLS_D) /* {{{ */ZEND_API const char *get_active_function_name(TSRMLS_D) /* {{{ */
 {  {
         if (!zend_is_executing(TSRMLS_C)) {          if (!zend_is_executing(TSRMLS_C)) {
                 return NULL;                  return NULL;
         }          }
         switch (EG(current_execute_data)->function_state.function->type) {          switch (EG(current_execute_data)->function_state.function->type) {
                 case ZEND_USER_FUNCTION: {                  case ZEND_USER_FUNCTION: {
                                char *function_name = ((zend_op_array *) EG(current_execute_data)->function_state.function)->function_name;                                const char *function_name = ((zend_op_array *) EG(current_execute_data)->function_state.function)->function_name;
   
                                 if (function_name) {                                  if (function_name) {
                                         return function_name;                                          return function_name;
Line 401  ZEND_API char *get_active_function_name(TSRMLS_D) /* { Line 394  ZEND_API char *get_active_function_name(TSRMLS_D) /* {
 }  }
 /* }}} */  /* }}} */
   
ZEND_API char *zend_get_executed_filename(TSRMLS_D) /* {{{ */ZEND_API const char *zend_get_executed_filename(TSRMLS_D) /* {{{ */
 {  {
         if (EG(active_op_array)) {          if (EG(active_op_array)) {
                 return EG(active_op_array)->filename;                  return EG(active_op_array)->filename;
Line 433  ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{  Line 426  ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ 
   
 ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */  ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
 {  {
         zval *zv = *zval_ptr;  
   
 #if DEBUG_ZEND>=2  #if DEBUG_ZEND>=2
         printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr) - 1);          printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr) - 1);
 #endif  #endif
        Z_DELREF_P(zv);        Z_DELREF_PP(zval_ptr);
        if (Z_REFCOUNT_P(zv) == 0) {        if (Z_REFCOUNT_PP(zval_ptr) == 0) {
                 TSRMLS_FETCH();                  TSRMLS_FETCH();
   
                if (zv != &EG(uninitialized_zval)) {                if (*zval_ptr != &EG(uninitialized_zval)) {
                        GC_REMOVE_ZVAL_FROM_BUFFER(zv);                        GC_REMOVE_ZVAL_FROM_BUFFER(*zval_ptr);
                        zval_dtor(zv);                        zval_dtor(*zval_ptr);
                        efree_rel(zv);                        efree_rel(*zval_ptr);
                 }                  }
         } else {          } else {
                 TSRMLS_FETCH();                  TSRMLS_FETCH();
   
                if (Z_REFCOUNT_P(zv) == 1) {                if (Z_REFCOUNT_PP(zval_ptr) == 1) {
                        Z_UNSET_ISREF_P(zv);                        Z_UNSET_ISREF_PP(zval_ptr);
                 }                  }
   
                GC_ZVAL_CHECK_POSSIBLE_ROOT(zv);                GC_ZVAL_CHECK_POSSIBLE_ROOT(*zval_ptr);
         }          }
 }  }
 /* }}} */  /* }}} */
Line 524  ZEND_API int zval_update_constant_ex(zval **pp, void * Line 515  ZEND_API int zval_update_constant_ex(zval **pp, void *
                 if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {                  if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {
                         char *actual = Z_STRVAL_P(p);                          char *actual = Z_STRVAL_P(p);
   
                        if ((colon = zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {                        if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {
                                 zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));                                  zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
                                 Z_STRLEN_P(p) -= ((colon - Z_STRVAL_P(p)) + 1);                                  Z_STRLEN_P(p) -= ((colon - Z_STRVAL_P(p)) + 1);
                                 if (inline_change) {                                  if (inline_change) {
                                         colon = estrndup(colon, Z_STRLEN_P(p));                                          colon = estrndup(colon, Z_STRLEN_P(p));
                                        efree(Z_STRVAL_P(p));                                        str_efree(Z_STRVAL_P(p));
                                         Z_STRVAL_P(p) = colon;                                          Z_STRVAL_P(p) = colon;
                                 } else {                                  } else {
                                         Z_STRVAL_P(p) = colon + 1;                                          Z_STRVAL_P(p) = colon + 1;
Line 565  ZEND_API int zval_update_constant_ex(zval **pp, void * Line 556  ZEND_API int zval_update_constant_ex(zval **pp, void *
                                         if (fix_save) {                                          if (fix_save) {
                                                 save--;                                                  save--;
                                         }                                          }
                                        if (inline_change) {                                        if (inline_change && !IS_INTERNED(save)) {
                                                 efree(save);                                                  efree(save);
                                         }                                          }
                                         save = NULL;                                          save = NULL;
                                 }                                  }
                                if (inline_change && save && save != actual) {                                if (inline_change && save && save != actual && !IS_INTERNED(save)) {
                                         efree(save);                                          efree(save);
                                 }                                  }
                                 zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",  actual,  actual);                                  zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",  actual,  actual);
Line 624  ZEND_API int zval_update_constant_ex(zval **pp, void * Line 615  ZEND_API int zval_update_constant_ex(zval **pp, void *
                                 continue;                                  continue;
                         }                          }
                         if (!zend_get_constant_ex(str_index, str_index_len - 3, &const_value, scope, str_index[str_index_len - 2] TSRMLS_CC)) {                          if (!zend_get_constant_ex(str_index, str_index_len - 3, &const_value, scope, str_index[str_index_len - 2] TSRMLS_CC)) {
                                char *actual, *save = str_index;                                char *actual;
                                if ((colon = zend_memrchr(str_index, ':', str_index_len - 3))) {                                const char *save = str_index;
                                 if ((colon = (char*)zend_memrchr(str_index, ':', str_index_len - 3))) {
                                         zend_error(E_ERROR, "Undefined class constant '%s'", str_index);                                          zend_error(E_ERROR, "Undefined class constant '%s'", str_index);
                                         str_index_len -= ((colon - str_index) + 1);                                          str_index_len -= ((colon - str_index) + 1);
                                         str_index = colon;                                          str_index = colon;
Line 772  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 764  int zend_call_function(zend_fcall_info *fci, zend_fcal
         zend_class_entry *called_scope = NULL;          zend_class_entry *called_scope = NULL;
         zval *current_this;          zval *current_this;
         zend_execute_data execute_data;          zend_execute_data execute_data;
           zend_fcall_info_cache fci_cache_local;
   
         *fci->retval_ptr_ptr = NULL;          *fci->retval_ptr_ptr = NULL;
   
Line 806  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 799  int zend_call_function(zend_fcall_info *fci, zend_fcal
         }          }
   
         if (!fci_cache || !fci_cache->initialized) {          if (!fci_cache || !fci_cache->initialized) {
                 zend_fcall_info_cache fci_cache_local;  
                 char *callable_name;                  char *callable_name;
                 char *error = NULL;                  char *error = NULL;
   
Line 861  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 853  int zend_call_function(zend_fcall_info *fci, zend_fcal
         for (i=0; i<fci->param_count; i++) {          for (i=0; i<fci->param_count; i++) {
                 zval *param;                  zval *param;
   
                if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION                 if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
                        && (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0                         if (!PZVAL_IS_REF(*fci->params[i]) && Z_REFCOUNT_PP(fci->params[i]) > 1) {
                        && !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) 
                        && PZVAL_IS_REF(*fci->params[i])) { 
                        ALLOC_ZVAL(param); 
                        *param = **(fci->params[i]); 
                        INIT_PZVAL(param); 
                        zval_copy_ctor(param); 
                } else if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) 
                        && !PZVAL_IS_REF(*fci->params[i])) { 
 
                        if (Z_REFCOUNT_PP(fci->params[i]) > 1) { 
                                 zval *new_zval;                                  zval *new_zval;
   
                                 if (fci->no_separation &&                                  if (fci->no_separation &&
                                     !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {                                      !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
                                        if(i) {                                        if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) {
                                                 /* hack to clean up the stack */                                                  /* hack to clean up the stack */
                                                 zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);                                                  zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);
                                                 zend_vm_stack_clear_multiple(TSRMLS_C);                                                  zend_vm_stack_clear_multiple(TSRMLS_C);
Line 901  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 883  int zend_call_function(zend_fcall_info *fci, zend_fcal
                         Z_ADDREF_PP(fci->params[i]);                          Z_ADDREF_PP(fci->params[i]);
                         Z_SET_ISREF_PP(fci->params[i]);                          Z_SET_ISREF_PP(fci->params[i]);
                         param = *fci->params[i];                          param = *fci->params[i];
                   } else if (PZVAL_IS_REF(*fci->params[i]) &&
                              /* don't separate references for __call */
                              (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) {
                           ALLOC_ZVAL(param);
                           *param = **(fci->params[i]);
                           INIT_PZVAL(param);
                           zval_copy_ctor(param);
                 } else if (*fci->params[i] != &EG(uninitialized_zval)) {                  } else if (*fci->params[i] != &EG(uninitialized_zval)) {
                         Z_ADDREF_PP(fci->params[i]);                          Z_ADDREF_PP(fci->params[i]);
                         param = *fci->params[i];                          param = *fci->params[i];
Line 1015  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 1004  int zend_call_function(zend_fcall_info *fci, zend_fcal
                 }                  }
   
                 if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {                  if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
                        efree(EX(function_state).function->common.function_name);                        efree((char*)EX(function_state).function->common.function_name);
                 }                  }
                 efree(EX(function_state).function);                  efree(EX(function_state).function);
   
Line 1041  int zend_call_function(zend_fcall_info *fci, zend_fcal Line 1030  int zend_call_function(zend_fcall_info *fci, zend_fcal
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_lookup_class_ex(const char *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC) /* {{{ */ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC) /* {{{ */
 {  {
         zval **args[1];          zval **args[1];
         zval autoload_function;          zval autoload_function;
Line 1056  ZEND_API int zend_lookup_class_ex(const char *name, in Line 1045  ZEND_API int zend_lookup_class_ex(const char *name, in
         ulong hash;          ulong hash;
         ALLOCA_FLAG(use_heap)          ALLOCA_FLAG(use_heap)
   
        if (name == NULL || !name_length) {        if (key) {
                return FAILURE;                lc_name = Z_STRVAL(key->constant);
        }                lc_length = Z_STRLEN(key->constant) + 1;
                 hash = key->hash_value;
         } else {
                 if (name == NULL || !name_length) {
                         return FAILURE;
                 }
   
        lc_free = lc_name = do_alloca(name_length + 1, use_heap);                lc_free = lc_name = do_alloca(name_length + 1, use_heap);
        zend_str_tolower_copy(lc_name, name, name_length);                zend_str_tolower_copy(lc_name, name, name_length);
        lc_length = name_length + 1;                lc_length = name_length + 1;
   
        if (lc_name[0] == '\\') {                if (lc_name[0] == '\\') {
                lc_name += 1;                        lc_name += 1;
                lc_length -= 1;                        lc_length -= 1;
                 }
 
                 hash = zend_inline_hash_func(lc_name, lc_length);
         }          }
   
         hash = zend_inline_hash_func(lc_name, lc_length);  
   
         if (zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce) == SUCCESS) {          if (zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce) == SUCCESS) {
                free_alloca(lc_free, use_heap);                if (!key) {
                         free_alloca(lc_free, use_heap);
                 }
                 return SUCCESS;                  return SUCCESS;
         }          }
   
Line 1080  ZEND_API int zend_lookup_class_ex(const char *name, in Line 1077  ZEND_API int zend_lookup_class_ex(const char *name, in
          * (doesn't impact fuctionality of __autoload()           * (doesn't impact fuctionality of __autoload()
         */          */
         if (!use_autoload || zend_is_compiling(TSRMLS_C)) {          if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
                free_alloca(lc_free, use_heap);                if (!key) {
                         free_alloca(lc_free, use_heap);
                 }
                 return FAILURE;                  return FAILURE;
         }          }
   
Line 1090  ZEND_API int zend_lookup_class_ex(const char *name, in Line 1089  ZEND_API int zend_lookup_class_ex(const char *name, in
         }          }
   
         if (zend_hash_quick_add(EG(in_autoload), lc_name, lc_length, hash, (void**)&dummy, sizeof(char), NULL) == FAILURE) {          if (zend_hash_quick_add(EG(in_autoload), lc_name, lc_length, hash, (void**)&dummy, sizeof(char), NULL) == FAILURE) {
                free_alloca(lc_free, use_heap);                if (!key) {
                         free_alloca(lc_free, use_heap);
                 }
                 return FAILURE;                  return FAILURE;
         }          }
   
Line 1136  ZEND_API int zend_lookup_class_ex(const char *name, in Line 1137  ZEND_API int zend_lookup_class_ex(const char *name, in
                 zval_ptr_dtor(&retval_ptr);                  zval_ptr_dtor(&retval_ptr);
         }          }
   
        if (retval == FAILURE) {        if (retval == SUCCESS) {
                 retval = zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce);
         }
         if (!key) {
                 free_alloca(lc_free, use_heap);                  free_alloca(lc_free, use_heap);
                 return FAILURE;  
         }          }
   
         retval = zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce);  
         free_alloca(lc_free, use_heap);  
         return retval;          return retval;
 }  }
 /* }}} */  /* }}} */
   
 ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) /* {{{ */  ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) /* {{{ */
 {  {
        return zend_lookup_class_ex(name, name_length, 1, ce TSRMLS_CC);        return zend_lookup_class_ex(name, name_length, NULL, 1, ce TSRMLS_CC);
 }  }
 /* }}} */  /* }}} */
   
Line 1195  ZEND_API int zend_eval_stringl(char *str, int str_len, Line 1195  ZEND_API int zend_eval_stringl(char *str, int str_len,
                 }                  }
                 CG(interactive) = 0;                  CG(interactive) = 0;
   
                zend_execute(new_op_array TSRMLS_CC);                zend_try {
                         zend_execute(new_op_array TSRMLS_CC);
                 } zend_catch {
                         destroy_op_array(new_op_array TSRMLS_CC);
                         efree(new_op_array);
                         zend_bailout();
                 } zend_end_try();
   
                 CG(interactive) = orig_interactive;                  CG(interactive) = orig_interactive;
                 if (local_retval_ptr) {                  if (local_retval_ptr) {
Line 1259  void execute_new_code(TSRMLS_D) /* {{{ */ Line 1265  void execute_new_code(TSRMLS_D) /* {{{ */
         int orig_interactive;          int orig_interactive;
   
         if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE)          if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE)
                || CG(active_op_array)->backpatch_count>0                || CG(context).backpatch_count>0
                 || CG(active_op_array)->function_name                  || CG(active_op_array)->function_name
                 || CG(active_op_array)->type!=ZEND_USER_FUNCTION) {                  || CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
                 return;                  return;
Line 1267  void execute_new_code(TSRMLS_D) /* {{{ */ Line 1273  void execute_new_code(TSRMLS_D) /* {{{ */
   
         ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);          ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);
         ret_opline->opcode = ZEND_RETURN;          ret_opline->opcode = ZEND_RETURN;
        ret_opline->op1.op_type = IS_CONST;        ret_opline->op1_type = IS_CONST;
        INIT_ZVAL(ret_opline->op1.u.constant);        ret_opline->op1.constant = zend_add_literal(CG(active_op_array), &EG(uninitialized_zval) TSRMLS_CC);
         SET_UNUSED(ret_opline->op2);          SET_UNUSED(ret_opline->op2);
   
        if (!CG(active_op_array)->start_op) {        if (!EG(start_op)) {
                CG(active_op_array)->start_op = CG(active_op_array)->opcodes;                EG(start_op) = CG(active_op_array)->opcodes;
         }          }
   
        opline=CG(active_op_array)->start_op;        opline=EG(start_op);
         end=CG(active_op_array)->opcodes+CG(active_op_array)->last;          end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
   
         while (opline<end) {          while (opline<end) {
                if (opline->op1.op_type == IS_CONST) {                if (opline->op1_type == IS_CONST) {
                        Z_SET_ISREF(opline->op1.u.constant);                        opline->op1.zv = &CG(active_op_array)->literals[opline->op1.constant].constant;
                        Z_SET_REFCOUNT(opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */ 
                 }                  }
                if (opline->op2.op_type == IS_CONST) {                if (opline->op2_type == IS_CONST) {
                        Z_SET_ISREF(opline->op2.u.constant);                        opline->op2.zv = &CG(active_op_array)->literals[opline->op2.constant].constant;
                        Z_SET_REFCOUNT(opline->op2.u.constant, 2); 
                 }                  }
                 switch (opline->opcode) {                  switch (opline->opcode) {
                         case ZEND_GOTO:                          case ZEND_GOTO:
                                if (Z_TYPE(opline->op2.u.constant) != IS_LONG) {                                if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {
                                         zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC);                                          zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC);
                                 }                                  }
                                 /* break omitted intentionally */                                  /* break omitted intentionally */
                         case ZEND_JMP:                          case ZEND_JMP:
                                opline->op1.u.jmp_addr = &CG(active_op_array)->opcodes[opline->op1.u.opline_num];                                opline->op1.jmp_addr = &CG(active_op_array)->opcodes[opline->op1.opline_num];
                                 break;                                  break;
                         case ZEND_JMPZ:                          case ZEND_JMPZ:
                         case ZEND_JMPNZ:                          case ZEND_JMPNZ:
                         case ZEND_JMPZ_EX:                          case ZEND_JMPZ_EX:
                         case ZEND_JMPNZ_EX:                          case ZEND_JMPNZ_EX:
                         case ZEND_JMP_SET:                          case ZEND_JMP_SET:
                                opline->op2.u.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.u.opline_num];                        case ZEND_JMP_SET_VAR:
                                 opline->op2.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.opline_num];
                                 break;                                  break;
                 }                  }
                 ZEND_VM_SET_OPCODE_HANDLER(opline);                  ZEND_VM_SET_OPCODE_HANDLER(opline);
Line 1322  void execute_new_code(TSRMLS_D) /* {{{ */ Line 1327  void execute_new_code(TSRMLS_D) /* {{{ */
         }          }
   
         CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */          CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */
        CG(active_op_array)->start_op = CG(active_op_array)->opcodes+CG(active_op_array)->last;        EG(start_op) = CG(active_op_array)->opcodes+CG(active_op_array)->last;
 }  }
 /* }}} */  /* }}} */
   
Line 1331  ZEND_API void zend_timeout(int dummy) /* {{{ */ Line 1336  ZEND_API void zend_timeout(int dummy) /* {{{ */
         TSRMLS_FETCH();          TSRMLS_FETCH();
   
         if (zend_on_timeout) {          if (zend_on_timeout) {
   #ifdef ZEND_SIGNALS
                   /* 
                      We got here because we got a timeout signal, so we are in a signal handler
                      at this point. However, we want to be able to timeout any user-supplied
                      shutdown functions, so pretend we are not in a signal handler while we are
                      calling these 
                   */
                   SIGG(running) = 0;
   #endif
                 zend_on_timeout(EG(timeout_seconds) TSRMLS_CC);                  zend_on_timeout(EG(timeout_seconds) TSRMLS_CC);
         }          }
   
Line 1472  void zend_set_timeout(long seconds, int reset_signals) Line 1486  void zend_set_timeout(long seconds, int reset_signals)
 #       ifdef HAVE_SETITIMER  #       ifdef HAVE_SETITIMER
         {          {
                 struct itimerval t_r;           /* timeout requested */                  struct itimerval t_r;           /* timeout requested */
                sigset_t sigset;                int signo;
   
                 if(seconds) {                  if(seconds) {
                         t_r.it_value.tv_sec = seconds;                          t_r.it_value.tv_sec = seconds;
Line 1481  void zend_set_timeout(long seconds, int reset_signals) Line 1495  void zend_set_timeout(long seconds, int reset_signals)
 #       ifdef __CYGWIN__  #       ifdef __CYGWIN__
                         setitimer(ITIMER_REAL, &t_r, NULL);                          setitimer(ITIMER_REAL, &t_r, NULL);
                 }                  }
                if(reset_signals) {                signo = SIGALRM;
                        signal(SIGALRM, zend_timeout); 
                        sigemptyset(&sigset); 
                        sigaddset(&sigset, SIGALRM); 
                } 
 #       else  #       else
                         setitimer(ITIMER_PROF, &t_r, NULL);                          setitimer(ITIMER_PROF, &t_r, NULL);
                 }                  }
                if(reset_signals) {                signo = SIGPROF;
                        signal(SIGPROF, zend_timeout); 
                        sigemptyset(&sigset); 
                        sigaddset(&sigset, SIGPROF); 
                } 
 #       endif  #       endif
                if(reset_signals) {
                 if (reset_signals) {
 #       ifdef ZEND_SIGNALS
                         zend_signal(signo, zend_timeout TSRMLS_CC);
 #       else
                         sigset_t sigset;
 
                         signal(signo, zend_timeout);
                         sigemptyset(&sigset);
                         sigaddset(&sigset, signo);
                         sigprocmask(SIG_UNBLOCK, &sigset, NULL);                          sigprocmask(SIG_UNBLOCK, &sigset, NULL);
   #       endif
                 }                  }
         }          }
#       endif#       endif /* HAVE_SETITIMER */
 #endif  #endif
 }  }
 /* }}} */  /* }}} */
Line 1565  check_fetch_type: Line 1581  check_fetch_type:
                         break;                          break;
         }          }
   
        if (zend_lookup_class_ex(class_name, class_name_len, use_autoload, &pce TSRMLS_CC) == FAILURE) {        if (zend_lookup_class_ex(class_name, class_name_len, NULL, use_autoload, &pce TSRMLS_CC) == FAILURE) {
                 if (use_autoload) {                  if (use_autoload) {
                         if (!silent && !EG(exception)) {                          if (!silent && !EG(exception)) {
                                 if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {                                  if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
                                         zend_error(E_ERROR, "Interface '%s' not found", class_name);                                          zend_error(E_ERROR, "Interface '%s' not found", class_name);
                                   } else if (fetch_type == ZEND_FETCH_CLASS_TRAIT) {
                           zend_error(E_ERROR, "Trait '%s' not found", class_name);
                   } else {
                                           zend_error(E_ERROR, "Class '%s' not found", class_name);
                                   }       
                           }
                   }
                   return NULL;
           }
           return *pce;
   }
   /* }}} */
   
   zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC) /* {{{ */
   {
           zend_class_entry **pce;
           int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
   
           if (zend_lookup_class_ex(class_name, class_name_len, key, use_autoload, &pce TSRMLS_CC) == FAILURE) {
                   if (use_autoload) {
                           if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
                                   if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
                                           zend_error(E_ERROR, "Interface '%s' not found", class_name);
                                   } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
                                           zend_error(E_ERROR, "Trait '%s' not found", class_name);
                                 } else {                                  } else {
                                         zend_error(E_ERROR, "Class '%s' not found", class_name);                                          zend_error(E_ERROR, "Class '%s' not found", class_name);
                                 }                                         }       
Line 1653  ZEND_API void zend_reset_all_cv(HashTable *symbol_tabl Line 1694  ZEND_API void zend_reset_all_cv(HashTable *symbol_tabl
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC) /* {{{ */ZEND_API void zend_delete_variable(zend_execute_data *ex, HashTable *ht, const char *name, int name_len, ulong hash_value TSRMLS_DC) /* {{{ */
 {  {
           if (zend_hash_quick_del(ht, name, name_len, hash_value) == SUCCESS) {
                   name_len--;
                   while (ex && ex->symbol_table == ht) {
                           int i;
   
                           if (ex->op_array) {
                                   for (i = 0; i < ex->op_array->last_var; i++) {
                                           if (ex->op_array->vars[i].hash_value == hash_value &&
                                                   ex->op_array->vars[i].name_len == name_len &&
                                                   !memcmp(ex->op_array->vars[i].name, name, name_len)) {
                                                   ex->CVs[i] = NULL;
                                                   break;
                                           }
                                   }
                           }
                           ex = ex->prev_execute_data;
                   }
           }
   }
   /* }}} */
   
   ZEND_API int zend_delete_global_variable_ex(const char *name, int name_len, ulong hash_value TSRMLS_DC) /* {{{ */
   {
         zend_execute_data *ex;          zend_execute_data *ex;
         ulong hash_value = zend_inline_hash_func(name, name_len + 1);  
   
         if (zend_hash_quick_exists(&EG(symbol_table), name, name_len + 1, hash_value)) {          if (zend_hash_quick_exists(&EG(symbol_table), name, name_len + 1, hash_value)) {
                 for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {                  for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {
Line 1679  ZEND_API int zend_delete_global_variable(char *name, i Line 1742  ZEND_API int zend_delete_global_variable(char *name, i
 }  }
 /* }}} */  /* }}} */
   
   ZEND_API int zend_delete_global_variable(const char *name, int name_len TSRMLS_DC) /* {{{ */
   {
           return zend_delete_global_variable_ex(name, name_len, zend_inline_hash_func(name, name_len + 1) TSRMLS_CC);
   }
   /* }}} */
   
 ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */  ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
 {  {
         zend_uint i;          zend_uint i;
Line 1702  ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* { Line 1771  ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {
                                 EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);                                  EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);
                         } else {                          } else {
                                 ALLOC_HASHTABLE(EG(active_symbol_table));                                  ALLOC_HASHTABLE(EG(active_symbol_table));
                                zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);                                zend_hash_init(EG(active_symbol_table), ex->op_array->last_var, NULL, ZVAL_PTR_DTOR, 0);
                                 /*printf("Cache miss!  Initialized %x\n", EG(active_symbol_table));*/                                  /*printf("Cache miss!  Initialized %x\n", EG(active_symbol_table));*/
                         }                          }
                         ex->symbol_table = EG(active_symbol_table);                          ex->symbol_table = EG(active_symbol_table);

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>