PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_execute_API.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 651 767 84.9 %
Date: 2015-09-02 Functions: 41 46 89.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    |          Dmitry Stogov <dmitry@zend.com>                             |
      18             :    +----------------------------------------------------------------------+
      19             : */
      20             : 
      21             : /* $Id$ */
      22             : 
      23             : #include <stdio.h>
      24             : #include <signal.h>
      25             : 
      26             : #include "zend.h"
      27             : #include "zend_compile.h"
      28             : #include "zend_execute.h"
      29             : #include "zend_API.h"
      30             : #include "zend_stack.h"
      31             : #include "zend_constants.h"
      32             : #include "zend_extensions.h"
      33             : #include "zend_exceptions.h"
      34             : #include "zend_closures.h"
      35             : #include "zend_generators.h"
      36             : #include "zend_vm.h"
      37             : #include "zend_float.h"
      38             : #ifdef HAVE_SYS_TIME_H
      39             : #include <sys/time.h>
      40             : #endif
      41             : 
      42             : ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
      43             : ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
      44             : 
      45             : /* true globals */
      46             : ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, {{0}, {{0}}, {0}}, NULL, NULL, NULL, NULL, 0, 0 };
      47             : ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { 0, NULL, NULL, NULL, NULL };
      48             : 
      49             : #ifdef ZEND_WIN32
      50             : ZEND_TLS HANDLE tq_timer = NULL;
      51             : #endif
      52             : 
      53             : #if 0&&ZEND_DEBUG
      54             : static void (*original_sigsegv_handler)(int);
      55             : static void zend_handle_sigsegv(int dummy) /* {{{ */
      56             : {
      57             :         fflush(stdout);
      58             :         fflush(stderr);
      59             :         if (original_sigsegv_handler == zend_handle_sigsegv) {
      60             :                 signal(SIGSEGV, original_sigsegv_handler);
      61             :         } else {
      62             :                 signal(SIGSEGV, SIG_DFL);
      63             :         }
      64             :         {
      65             : 
      66             :                 fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
      67             :                                 active_opline->opcode,
      68             :                                 active_opline-EG(active_op_array)->opcodes,
      69             :                                 get_active_function_name(),
      70             :                                 zend_get_executed_filename(),
      71             :                                 zend_get_executed_lineno());
      72             : /* See http://support.microsoft.com/kb/190351 */
      73             : #ifdef ZEND_WIN32
      74             :                 fflush(stderr);
      75             : #endif
      76             :         }
      77             :         if (original_sigsegv_handler!=zend_handle_sigsegv) {
      78             :                 original_sigsegv_handler(dummy);
      79             :         }
      80             : }
      81             : /* }}} */
      82             : #endif
      83             : 
      84       21126 : static void zend_extension_activator(zend_extension *extension) /* {{{ */
      85             : {
      86       21126 :         if (extension->activate) {
      87         374 :                 extension->activate();
      88             :         }
      89       21126 : }
      90             : /* }}} */
      91             : 
      92       21167 : static void zend_extension_deactivator(zend_extension *extension) /* {{{ */
      93             : {
      94       21167 :         if (extension->deactivate) {
      95         374 :                 extension->deactivate();
      96             :         }
      97       21167 : }
      98             : /* }}} */
      99             : 
     100       42763 : static int clean_non_persistent_function(zval *zv) /* {{{ */
     101             : {
     102       42763 :         zend_function *function = Z_PTR_P(zv);
     103       42763 :         return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
     104             : }
     105             : /* }}} */
     106             : 
     107           0 : ZEND_API int clean_non_persistent_function_full(zval *zv) /* {{{ */
     108             : {
     109           0 :         zend_function *function = Z_PTR_P(zv);
     110           0 :         return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
     111             : }
     112             : /* }}} */
     113             : 
     114       30584 : static int clean_non_persistent_class(zval *zv) /* {{{ */
     115             : {
     116       30584 :         zend_class_entry *ce = Z_PTR_P(zv);
     117       30584 :         return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
     118             : }
     119             : /* }}} */
     120             : 
     121           0 : ZEND_API int clean_non_persistent_class_full(zval *zv) /* {{{ */
     122             : {
     123           0 :         zend_class_entry *ce = Z_PTR_P(zv);
     124           0 :         return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
     125             : }
     126             : /* }}} */
     127             : 
     128       21254 : void init_executor(void) /* {{{ */
     129             : {
     130       21254 :         zend_init_fpu();
     131             : 
     132       21254 :         ZVAL_NULL(&EG(uninitialized_zval));
     133       21254 :         ZVAL_NULL(&EG(error_zval));
     134             : /* destroys stack frame, therefore makes core dumps worthless */
     135             : #if 0&&ZEND_DEBUG
     136             :         original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
     137             : #endif
     138             : 
     139       21254 :         EG(symtable_cache_ptr) = EG(symtable_cache) - 1;
     140       21254 :         EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1;
     141       21254 :         EG(no_extensions) = 0;
     142             : 
     143       21254 :         EG(function_table) = CG(function_table);
     144       21254 :         EG(class_table) = CG(class_table);
     145             : 
     146       21254 :         EG(in_autoload) = NULL;
     147       21254 :         EG(autoload_func) = NULL;
     148       21254 :         EG(error_handling) = EH_NORMAL;
     149             : 
     150       21254 :         zend_vm_stack_init();
     151             : 
     152       21254 :         zend_hash_init(&EG(symbol_table), 64, NULL, ZVAL_PTR_DTOR, 0);
     153       21254 :         EG(valid_symbol_table) = 1;
     154             : 
     155       21254 :         zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator);
     156             : 
     157       21254 :         zend_hash_init(&EG(included_files), 8, NULL, NULL, 0);
     158             : 
     159       21254 :         EG(ticks_count) = 0;
     160             : 
     161       21254 :         ZVAL_UNDEF(&EG(user_error_handler));
     162             : 
     163       21254 :         EG(current_execute_data) = NULL;
     164             : 
     165       21254 :         zend_stack_init(&EG(user_error_handlers_error_reporting), sizeof(int));
     166       21254 :         zend_stack_init(&EG(user_error_handlers), sizeof(zval));
     167       21254 :         zend_stack_init(&EG(user_exception_handlers), sizeof(zval));
     168             : 
     169       21254 :         zend_objects_store_init(&EG(objects_store), 1024);
     170             : 
     171       21254 :         EG(full_tables_cleanup) = 0;
     172             : #ifdef ZEND_WIN32
     173             :         EG(timed_out) = 0;
     174             : #endif
     175             : 
     176       21254 :         EG(exception) = NULL;
     177       21254 :         EG(prev_exception) = NULL;
     178             : 
     179       21254 :         EG(scope) = NULL;
     180             : 
     181       21254 :         EG(ht_iterators_count) = sizeof(EG(ht_iterators_slots)) / sizeof(HashTableIterator);
     182       21254 :         EG(ht_iterators_used) = 0;
     183       21254 :         EG(ht_iterators) = EG(ht_iterators_slots);
     184       21254 :         memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots)));
     185             : 
     186       21254 :         EG(active) = 1;
     187       21254 : }
     188             : /* }}} */
     189             : 
     190      270596 : static int zval_call_destructor(zval *zv) /* {{{ */
     191             : {
     192      270596 :         if (Z_TYPE_P(zv) == IS_INDIRECT) {
     193        2412 :                 zv = Z_INDIRECT_P(zv);
     194             :         }
     195      279965 :         if (Z_TYPE_P(zv) == IS_OBJECT && Z_REFCOUNT_P(zv) == 1) {
     196        8651 :                 return ZEND_HASH_APPLY_REMOVE;
     197             :         } else {
     198      261945 :                 return ZEND_HASH_APPLY_KEEP;
     199             :         }
     200             : }
     201             : /* }}} */
     202             : 
     203       17494 : static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */
     204             : {
     205       17494 :         if (Z_TYPE_P(zv) == IS_INDIRECT) {
     206        2100 :                 zv = Z_INDIRECT_P(zv);
     207             :         }
     208             :         i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC);
     209       17494 : }
     210             : /* }}} */
     211             : 
     212          33 : static void zend_throw_or_error(int fetch_type, zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
     213             : {
     214             :         va_list va;
     215          33 :         char *message = NULL;
     216             : 
     217          33 :         va_start(va, format);
     218          33 :         zend_vspprintf(&message, 0, format, va);
     219             : 
     220          33 :         if (fetch_type & ZEND_FETCH_CLASS_EXCEPTION) {
     221          21 :                 zend_throw_error(exception_ce, message);
     222             :         } else {
     223          12 :                 zend_error(E_ERROR, message);
     224             :         }
     225             : 
     226          21 :         efree(message);
     227          21 :         va_end(va);
     228          21 : }
     229             : /* }}} */
     230             : 
     231       21292 : void shutdown_destructors(void) /* {{{ */
     232             : {
     233       21292 :         if (CG(unclean_shutdown)) {
     234        1990 :                 EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;
     235             :         }
     236       21292 :         zend_try {
     237             :                 uint32_t symbols;
     238             :                 do {
     239       26329 :                         symbols = zend_hash_num_elements(&EG(symbol_table));
     240       26329 :                         zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor);
     241       26329 :                 } while (symbols != zend_hash_num_elements(&EG(symbol_table)));
     242       21292 :                 zend_objects_store_call_destructors(&EG(objects_store));
     243           0 :         } zend_catch {
     244             :                 /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
     245           0 :                 zend_objects_store_mark_destructed(&EG(objects_store));
     246       21292 :         } zend_end_try();
     247       21292 : }
     248             : /* }}} */
     249             : 
     250       21292 : void shutdown_executor(void) /* {{{ */
     251             : {
     252             :         zend_function *func;
     253             :         zend_class_entry *ce;
     254             : 
     255       21292 :         zend_try {
     256             : 
     257             : /* Removed because this can not be safely done, e.g. in this situation:
     258             :    Object 1 creates object 2
     259             :    Object 3 holds reference to object 2.
     260             :    Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with
     261             :    very problematic results */
     262             : /*              zend_objects_store_call_destructors(&EG(objects_store)); */
     263             : 
     264             : /* Moved after symbol table cleaners, because  some of the cleaners can call
     265             :    destructors, which would use EG(symtable_cache_ptr) and thus leave leaks */
     266             : /*              while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
     267             :                         zend_hash_destroy(*EG(symtable_cache_ptr));
     268             :                         efree(*EG(symtable_cache_ptr));
     269             :                         EG(symtable_cache_ptr)--;
     270             :                 }
     271             : */
     272       21292 :                 zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator);
     273             : 
     274       21292 :                 if (CG(unclean_shutdown)) {
     275        1996 :                         EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;
     276             :                 }
     277       21292 :                 zend_hash_graceful_reverse_destroy(&EG(symbol_table));
     278       21292 :         } zend_end_try();
     279       21292 :         EG(valid_symbol_table) = 0;
     280             : 
     281       21292 :         zend_try {
     282             :                 zval *zeh;
     283             :                 /* remove error handlers before destroying classes and functions,
     284             :                  * so that if handler used some class, crash would not happen */
     285       21292 :                 if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
     286         233 :                         zeh = &EG(user_error_handler);
     287         233 :                         zval_ptr_dtor(zeh);
     288         233 :                         ZVAL_UNDEF(&EG(user_error_handler));
     289             :                 }
     290             : 
     291       21292 :                 if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
     292          11 :                         zeh = &EG(user_exception_handler);
     293          11 :                         zval_ptr_dtor(zeh);
     294          11 :                         ZVAL_UNDEF(&EG(user_exception_handler));
     295             :                 }
     296             : 
     297       21292 :                 zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
     298       21292 :                 zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1);
     299       21292 :                 zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1);
     300       21292 :         } zend_end_try();
     301             : 
     302       21292 :         zend_try {
     303             :                 /* Cleanup static data for functions and arrays.
     304             :                  * We need a separate cleanup stage because of the following problem:
     305             :                  * Suppose we destroy class X, which destroys the class's function table,
     306             :                  * and in the function table we have function foo() that has static $bar.
     307             :                  * Now if an object of class X is assigned to $bar, its destructor will be
     308             :                  * called and will fail since X's function table is in mid-destruction.
     309             :                  * So we want first of all to clean up all data and then move to tables destruction.
     310             :                  * Note that only run-time accessed data need to be cleaned up, pre-defined data can
     311             :                  * not contain objects and thus are not probelmatic */
     312       21292 :                 if (EG(full_tables_cleanup)) {
     313           0 :                         ZEND_HASH_FOREACH_PTR(EG(function_table), func) {
     314           0 :                                 if (func->type == ZEND_USER_FUNCTION) {
     315           0 :                                         zend_cleanup_op_array_data((zend_op_array *) func);
     316             :                                 }
     317             :                         } ZEND_HASH_FOREACH_END();
     318           0 :                         ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
     319           0 :                                 if (ce->type == ZEND_USER_CLASS) {
     320           0 :                                         zend_cleanup_user_class_data(ce);
     321             :                                 } else {
     322           0 :                                         zend_cleanup_internal_class_data(ce);
     323             :                                 }
     324             :                         } ZEND_HASH_FOREACH_END();
     325             :                 } else {
     326      113212 :                         ZEND_HASH_REVERSE_FOREACH_PTR(EG(function_table), func) {
     327       42763 :                                 if (func->type != ZEND_USER_FUNCTION) {
     328       21292 :                                         break;
     329             :                                 }
     330       21471 :                                 zend_cleanup_op_array_data((zend_op_array *) func);
     331             :                         } ZEND_HASH_FOREACH_END();
     332       72454 :                         ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
     333       30582 :                                 if (ce->type != ZEND_USER_CLASS) {
     334       21290 :                                         break;
     335             :                                 }
     336        9292 :                                 zend_cleanup_user_class_data(ce);
     337             :                         } ZEND_HASH_FOREACH_END();
     338       21290 :                         zend_cleanup_internal_classes();
     339             :                 }
     340       21292 :         } zend_end_try();
     341             : 
     342       21292 :         zend_try {
     343       21292 :                 zend_llist_destroy(&CG(open_files));
     344       21292 :         } zend_end_try();
     345             : 
     346       21292 :         zend_try {
     347       21292 :                 zend_close_rsrc_list(&EG(regular_list));
     348       21292 :         } zend_end_try();
     349             : 
     350             : #if ZEND_DEBUG
     351             :         if (GC_G(gc_enabled) && !CG(unclean_shutdown)) {
     352             :                 gc_collect_cycles();
     353             :         }
     354             : #endif
     355             : 
     356       21292 :         zend_try {
     357       21292 :                 zend_objects_store_free_object_storage(&EG(objects_store));
     358             : 
     359       21292 :                 zend_vm_stack_destroy();
     360             : 
     361             :                 /* Destroy all op arrays */
     362       21292 :                 if (EG(full_tables_cleanup)) {
     363           0 :                         zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);
     364           0 :                         zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full);
     365             :                 } else {
     366       21292 :                         zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function);
     367       21292 :                         zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class);
     368             :                 }
     369             : 
     370       42866 :                 while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
     371         282 :                         zend_hash_destroy(*EG(symtable_cache_ptr));
     372         282 :                         FREE_HASHTABLE(*EG(symtable_cache_ptr));
     373         282 :                         EG(symtable_cache_ptr)--;
     374             :                 }
     375       21292 :         } zend_end_try();
     376             : 
     377       21292 :         zend_try {
     378       21292 :                 clean_non_persistent_constants();
     379       21292 :         } zend_end_try();
     380             : 
     381       21292 :         zend_try {
     382             : #if 0&&ZEND_DEBUG
     383             :         signal(SIGSEGV, original_sigsegv_handler);
     384             : #endif
     385             : 
     386       21292 :                 zend_hash_destroy(&EG(included_files));
     387             : 
     388       21292 :                 zend_stack_destroy(&EG(user_error_handlers_error_reporting));
     389       21292 :                 zend_stack_destroy(&EG(user_error_handlers));
     390       21292 :                 zend_stack_destroy(&EG(user_exception_handlers));
     391       21292 :                 zend_objects_store_destroy(&EG(objects_store));
     392       21292 :                 if (EG(in_autoload)) {
     393          89 :                         zend_hash_destroy(EG(in_autoload));
     394          89 :                         FREE_HASHTABLE(EG(in_autoload));
     395             :                 }
     396       21292 :         } zend_end_try();
     397             : 
     398       21292 :         zend_shutdown_fpu();
     399             : 
     400       21292 :         EG(ht_iterators_used) = 0;
     401       21292 :         if (EG(ht_iterators) != EG(ht_iterators_slots)) {
     402           0 :                 efree(EG(ht_iterators));
     403             :         }
     404             : 
     405       21292 :         EG(active) = 0;
     406       21292 : }
     407             : /* }}} */
     408             : 
     409             : /* return class name and "::" or "". */
     410      213940 : ZEND_API const char *get_active_class_name(const char **space) /* {{{ */
     411             : {
     412             :         zend_function *func;
     413             : 
     414      213940 :         if (!zend_is_executing()) {
     415           0 :                 if (space) {
     416           0 :                         *space = "";
     417             :                 }
     418           0 :                 return "";
     419             :         }
     420             : 
     421      213940 :         func = EG(current_execute_data)->func;
     422      213940 :         switch (func->type) {
     423             :                 case ZEND_USER_FUNCTION:
     424             :                 case ZEND_INTERNAL_FUNCTION:
     425             :                 {
     426      213940 :                         zend_class_entry *ce = func->common.scope;
     427             : 
     428      213940 :                         if (space) {
     429      213940 :                                 *space = ce ? "::" : "";
     430             :                         }
     431      213940 :                         return ce ? ZSTR_VAL(ce->name) : "";
     432             :                 }
     433             :                 default:
     434           0 :                         if (space) {
     435           0 :                                 *space = "";
     436             :                         }
     437           0 :                         return "";
     438             :         }
     439             : }
     440             : /* }}} */
     441             : 
     442      213962 : ZEND_API const char *get_active_function_name(void) /* {{{ */
     443             : {
     444             :         zend_function *func;
     445             : 
     446      213962 :         if (!zend_is_executing()) {
     447          14 :                 return NULL;
     448             :         }
     449      213948 :         func = EG(current_execute_data)->func;
     450      213948 :         switch (func->type) {
     451             :                 case ZEND_USER_FUNCTION: {
     452         207 :                                 zend_string *function_name = func->common.function_name;
     453             : 
     454         207 :                                 if (function_name) {
     455         150 :                                         return ZSTR_VAL(function_name);
     456             :                                 } else {
     457          57 :                                         return "main";
     458             :                                 }
     459             :                         }
     460             :                         break;
     461             :                 case ZEND_INTERNAL_FUNCTION:
     462      213741 :                         return ZSTR_VAL(func->common.function_name);
     463             :                         break;
     464             :                 default:
     465           0 :                         return NULL;
     466             :         }
     467             : }
     468             : /* }}} */
     469             : 
     470      403448 : ZEND_API const char *zend_get_executed_filename(void) /* {{{ */
     471             : {
     472      403448 :         zend_execute_data *ex = EG(current_execute_data);
     473             : 
     474     1031999 :         while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
     475      225103 :                 ex = ex->prev_execute_data;
     476             :         }
     477      403448 :         if (ex) {
     478      403427 :                 return ZSTR_VAL(ex->func->op_array.filename);
     479             :         } else {
     480          21 :                 return "[no active file]";
     481             :         }
     482             : }
     483             : /* }}} */
     484             : 
     485        5948 : ZEND_API zend_string *zend_get_executed_filename_ex(void) /* {{{ */
     486             : {
     487        5948 :         zend_execute_data *ex = EG(current_execute_data);
     488             : 
     489       11995 :         while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
     490          99 :                 ex = ex->prev_execute_data;
     491             :         }
     492        5948 :         if (ex) {
     493        5948 :                 return ex->func->op_array.filename;
     494             :         } else {
     495           0 :                 return NULL;
     496             :         }
     497             : }
     498             : /* }}} */
     499             : 
     500      402586 : ZEND_API uint zend_get_executed_lineno(void) /* {{{ */
     501             : {
     502      402586 :         zend_execute_data *ex = EG(current_execute_data);
     503             : 
     504     1029850 :         while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
     505      224678 :                 ex = ex->prev_execute_data;
     506             :         }
     507      402586 :         if (ex) {
     508      402579 :                 if (EG(exception) && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
     509           8 :                     ex->opline->lineno == 0 && EG(opline_before_exception)) {
     510           4 :                         return EG(opline_before_exception)->lineno;
     511             :                 }
     512      402567 :                 return ex->opline->lineno;
     513             :         } else {
     514          15 :                 return 0;
     515             :         }
     516             : }
     517             : /* }}} */
     518             : 
     519      856068 : ZEND_API zend_bool zend_is_executing(void) /* {{{ */
     520             : {
     521      856068 :         return EG(current_execute_data) != 0;
     522             : }
     523             : /* }}} */
     524             : 
     525     5320987 : ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
     526             : {
     527             :         i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_RELAY_CC);
     528     5320986 : }
     529             : /* }}} */
     530             : 
     531    32303202 : ZEND_API void _zval_internal_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
     532             : {
     533    32303202 :         if (Z_REFCOUNTED_P(zval_ptr)) {
     534             :                 Z_DELREF_P(zval_ptr);
     535     5871687 :                 if (Z_REFCOUNT_P(zval_ptr) == 0) {
     536     2138412 :                         _zval_internal_dtor_for_ptr(zval_ptr ZEND_FILE_LINE_CC);
     537             :                 }
     538             :         }
     539    32303202 : }
     540             : /* }}} */
     541             : 
     542             : #define IS_VISITED_CONSTANT                     0x80
     543             : #define IS_CONSTANT_VISITED(p)          (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
     544             : #define MARK_CONSTANT_VISITED(p)        Z_TYPE_INFO_P(p) |= IS_VISITED_CONSTANT
     545             : #define RESET_CONSTANT_VISITED(p)       Z_TYPE_INFO_P(p) &= ~IS_VISITED_CONSTANT
     546             : 
     547         652 : ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_class_entry *scope) /* {{{ */
     548             : {
     549             :         zval *const_value;
     550             :         char *colon;
     551             : 
     552         652 :         if (IS_CONSTANT_VISITED(p)) {
     553           2 :                 zend_throw_error(NULL, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
     554           2 :                 return FAILURE;
     555         650 :         } else if (Z_TYPE_P(p) == IS_CONSTANT) {
     556             : 
     557         466 :                 SEPARATE_ZVAL_NOREF(p);
     558         290 :                 MARK_CONSTANT_VISITED(p);
     559         290 :                 if (Z_CONST_FLAGS_P(p) & IS_CONSTANT_CLASS) {
     560             :                         ZEND_ASSERT(EG(current_execute_data));
     561           4 :                         if (inline_change) {
     562           4 :                                 zend_string_release(Z_STR_P(p));
     563             :                         }
     564           8 :                         if (EG(scope) && EG(scope)->name) {
     565           4 :                                 ZVAL_STR_COPY(p, EG(scope)->name);
     566             :                         } else {
     567           0 :                                 ZVAL_EMPTY_STRING(p);
     568             :                         }
     569         286 :                 } else if (UNEXPECTED((const_value = zend_get_constant_ex(Z_STR_P(p), scope, Z_CONST_FLAGS_P(p))) == NULL)) {
     570          26 :                         char *actual = Z_STRVAL_P(p);
     571             : 
     572          26 :                         if (UNEXPECTED(EG(exception))) {
     573           6 :                                 RESET_CONSTANT_VISITED(p);
     574           6 :                                 return FAILURE;
     575          40 :                         } else if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {
     576           0 :                                 zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(p));
     577           0 :                                 RESET_CONSTANT_VISITED(p);
     578           0 :                                 return FAILURE;
     579             :                         } else {
     580          20 :                                 zend_string *save = Z_STR_P(p);
     581             :                                 char *slash;
     582          20 :                                 size_t actual_len = Z_STRLEN_P(p);
     583          25 :                                 if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) && (slash = (char *)zend_memrchr(actual, '\\', actual_len))) {
     584           3 :                                         actual = slash + 1;
     585           3 :                                         actual_len -= (actual - Z_STRVAL_P(p));
     586           3 :                                         if (inline_change) {
     587           2 :                                                 zend_string *s = zend_string_init(actual, actual_len, 0);
     588           2 :                                                 Z_STR_P(p) = s;
     589           2 :                                                 Z_TYPE_FLAGS_P(p) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE;
     590             :                                         }
     591             :                                 }
     592          20 :                                 if (actual[0] == '\\') {
     593           0 :                                         if (inline_change) {
     594           0 :                                                 memmove(Z_STRVAL_P(p), Z_STRVAL_P(p)+1, Z_STRLEN_P(p));
     595           0 :                                                 --Z_STRLEN_P(p);
     596             :                                         } else {
     597           0 :                                                 ++actual;
     598             :                                         }
     599           0 :                                         --actual_len;
     600             :                                 }
     601          20 :                                 if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) == 0) {
     602          15 :                                         if (ZSTR_VAL(save)[0] == '\\') {
     603           0 :                                                 zend_throw_error(NULL, "Undefined constant '%s'", ZSTR_VAL(save) + 1);
     604             :                                         } else {
     605          15 :                                                 zend_throw_error(NULL, "Undefined constant '%s'", ZSTR_VAL(save));
     606             :                                         }
     607          15 :                                         if (inline_change) {
     608             :                                                 zend_string_release(save);
     609             :                                         }
     610          15 :                                         RESET_CONSTANT_VISITED(p);
     611          15 :                                         return FAILURE;
     612             :                                 } else {
     613           5 :                                         zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",  actual,  actual);
     614           5 :                                         if (!inline_change) {
     615           2 :                                                 ZVAL_STRINGL(p, actual, actual_len);
     616             :                                         } else {
     617           4 :                                                 Z_TYPE_INFO_P(p) = Z_REFCOUNTED_P(p) ?
     618             :                                                         IS_STRING_EX : IS_INTERNED_STRING_EX;
     619           4 :                                                 if (save && ZSTR_VAL(save) != actual) {
     620             :                                                         zend_string_release(save);
     621             :                                                 }
     622             :                                         }
     623             :                                 }
     624             :                         }
     625             :                 } else {
     626         254 :                         if (inline_change) {
     627         148 :                                 zend_string_release(Z_STR_P(p));
     628             :                         }
     629         254 :                         ZVAL_COPY_VALUE(p, const_value);
     630         254 :                         if (Z_OPT_CONSTANT_P(p)) {
     631           0 :                                 if (UNEXPECTED(zval_update_constant_ex(p, 1, NULL) != SUCCESS)) {
     632           0 :                                         RESET_CONSTANT_VISITED(p);
     633           0 :                                         return FAILURE;
     634             :                                 }
     635             :                         }
     636             :                         zval_opt_copy_ctor(p);
     637             :                 }
     638         360 :         } else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
     639             :                 zval tmp;
     640             : 
     641         112 :                 if (UNEXPECTED(zend_ast_evaluate(&tmp, Z_ASTVAL_P(p), scope) != SUCCESS)) {
     642          18 :                         return FAILURE;
     643             :                 }
     644          92 :                 if (inline_change) {
     645          54 :                         zval_ptr_dtor(p);
     646             :                 }
     647          92 :                 ZVAL_COPY_VALUE(p, &tmp);
     648             :         }
     649         603 :         return SUCCESS;
     650             : }
     651             : /* }}} */
     652             : 
     653           0 : ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change) /* {{{ */
     654             : {
     655           0 :         return zval_update_constant_ex(pp, inline_change, NULL);
     656             : }
     657             : /* }}} */
     658             : 
     659        1420 : int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]) /* {{{ */
     660             : {
     661        1420 :         return call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, 1, NULL);
     662             : }
     663             : /* }}} */
     664             : 
     665       10713 : int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table) /* {{{ */
     666             : {
     667             :         zend_fcall_info fci;
     668             : 
     669       10713 :         fci.size = sizeof(fci);
     670       10713 :         fci.function_table = function_table;
     671       10713 :         fci.object = object ? Z_OBJ_P(object) : NULL;
     672       10713 :         ZVAL_COPY_VALUE(&fci.function_name, function_name);
     673       10713 :         fci.retval = retval_ptr;
     674       10713 :         fci.param_count = param_count;
     675       10713 :         fci.params = params;
     676       10713 :         fci.no_separation = (zend_bool) no_separation;
     677       10713 :         fci.symbol_table = symbol_table;
     678             : 
     679       10713 :         return zend_call_function(&fci, NULL);
     680             : }
     681             : /* }}} */
     682             : 
     683      696176 : int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */
     684             : {
     685             :         uint32_t i;
     686      696176 :         zend_class_entry *calling_scope = NULL;
     687             :         zend_execute_data *call, dummy_execute_data;
     688             :         zend_fcall_info_cache fci_cache_local;
     689             :         zend_function *func;
     690             :         zend_class_entry *orig_scope;
     691             : 
     692      696176 :         ZVAL_UNDEF(fci->retval);
     693             : 
     694      696176 :         if (!EG(active)) {
     695           0 :                 return FAILURE; /* executor is already inactive */
     696             :         }
     697             : 
     698      696176 :         if (EG(exception)) {
     699           9 :                 return FAILURE; /* we would result in an instable executor otherwise */
     700             :         }
     701             : 
     702      696167 :         switch (fci->size) {
     703             :                 case sizeof(zend_fcall_info):
     704      696167 :                         break; /* nothing to do currently */
     705             :                 default:
     706           0 :                         zend_error_noreturn(E_CORE_ERROR, "Corrupted fcall_info provided to zend_call_function()");
     707             :                         break;
     708             :         }
     709             : 
     710      696167 :         orig_scope = EG(scope);
     711             : 
     712             :         /* Initialize execute_data */
     713      696167 :         if (!EG(current_execute_data)) {
     714             :                 /* This only happens when we're called outside any execute()'s
     715             :                  * It shouldn't be strictly necessary to NULL execute_data out,
     716             :                  * but it may make bugs easier to spot
     717             :                  */
     718       19783 :                 memset(&dummy_execute_data, 0, sizeof(zend_execute_data));
     719       19783 :                 EG(current_execute_data) = &dummy_execute_data;
     720     1707082 :         } else if (EG(current_execute_data)->func &&
     721      676371 :                    ZEND_USER_CODE(EG(current_execute_data)->func->common.type) &&
     722       88825 :                    EG(current_execute_data)->opline->opcode != ZEND_DO_FCALL &&
     723       88504 :                    EG(current_execute_data)->opline->opcode != ZEND_DO_ICALL &&
     724       88499 :                    EG(current_execute_data)->opline->opcode != ZEND_DO_UCALL &&
     725       88499 :                    EG(current_execute_data)->opline->opcode != ZEND_DO_FCALL_BY_NAME) {
     726             :                 /* Insert fake frame in case of include or magic calls */
     727       88499 :                 dummy_execute_data = *EG(current_execute_data);
     728       88499 :                 dummy_execute_data.prev_execute_data = EG(current_execute_data);
     729       88499 :                 dummy_execute_data.call = NULL;
     730       88499 :                 dummy_execute_data.opline = NULL;
     731       88499 :                 dummy_execute_data.func = NULL;
     732       88499 :                 EG(current_execute_data) = &dummy_execute_data;
     733             :         }
     734             : 
     735      696167 :         if (!fci_cache || !fci_cache->initialized) {
     736             :                 zend_string *callable_name;
     737      239346 :                 char *error = NULL;
     738             : 
     739      239346 :                 if (!fci_cache) {
     740       11511 :                         fci_cache = &fci_cache_local;
     741             :                 }
     742             : 
     743      239346 :                 if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error)) {
     744          78 :                         if (error) {
     745           0 :                                 zend_error(E_WARNING, "Invalid callback %s, %s", ZSTR_VAL(callable_name), error);
     746           0 :                                 efree(error);
     747             :                         }
     748          78 :                         if (callable_name) {
     749          78 :                                 zend_string_release(callable_name);
     750             :                         }
     751          78 :                         if (EG(current_execute_data) == &dummy_execute_data) {
     752          41 :                                 EG(current_execute_data) = dummy_execute_data.prev_execute_data;
     753             :                         }
     754          78 :                         return FAILURE;
     755      239268 :                 } else if (error) {
     756             :                         /* Capitalize the first latter of the error message */
     757           3 :                         if (error[0] >= 'a' && error[0] <= 'z') {
     758           3 :                                 error[0] += ('A' - 'a');
     759             :                         }
     760           3 :                         zend_error(E_DEPRECATED, "%s", error);
     761           3 :                         efree(error);
     762             :                 }
     763      239268 :                 zend_string_release(callable_name);
     764             :         }
     765             : 
     766      696089 :         func = fci_cache->function_handler;
     767     1392178 :         call = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_FUNCTION,
     768             :                 func, fci->param_count, fci_cache->called_scope, fci_cache->object);
     769      696089 :         calling_scope = fci_cache->calling_scope;
     770      696089 :         fci->object = fci_cache->object;
     771     1625689 :         if (fci->object &&
     772      464800 :             (!EG(objects_store).object_buckets ||
     773      464800 :              !IS_OBJ_VALID(EG(objects_store).object_buckets[fci->object->handle]))) {
     774           0 :                 if (EG(current_execute_data) == &dummy_execute_data) {
     775           0 :                         EG(current_execute_data) = dummy_execute_data.prev_execute_data;
     776             :                 }
     777           0 :                 return FAILURE;
     778             :         }
     779             : 
     780      696089 :         if (func->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
     781           0 :                 if (func->common.fn_flags & ZEND_ACC_ABSTRACT) {
     782           0 :                         zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(func->common.scope->name), ZSTR_VAL(func->common.function_name));
     783           0 :                         return FAILURE;
     784             :                 }
     785           0 :                 if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
     786           0 :                         zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
     787           0 :                                 func->common.scope ? ZSTR_VAL(func->common.scope->name) : "",
     788           0 :                                 func->common.scope ? "::" : "",
     789           0 :                                 ZSTR_VAL(func->common.function_name));
     790             :                 }
     791             :         }
     792             : 
     793     1180022 :         for (i=0; i<fci->param_count; i++) {
     794             :                 zval *param;
     795      483937 :                 zval *arg = &fci->params[i];
     796             : 
     797      967874 :                 if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) {
     798         351 :                         if (UNEXPECTED(!Z_ISREF_P(arg))) {
     799         249 :                                 if (fci->no_separation &&
     800           4 :                                         !ARG_MAY_BE_SENT_BY_REF(func, i + 1)) {
     801           4 :                                         if (i) {
     802             :                                                 /* hack to clean up the stack */
     803           0 :                                                 ZEND_CALL_NUM_ARGS(call) = i;
     804             :                                                 zend_vm_stack_free_args(call);
     805             :                                         }
     806             :                                         zend_vm_stack_free_call_frame(call);
     807             : 
     808          14 :                                         zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
     809             :                                                 i+1,
     810           6 :                                                 func->common.scope ? ZSTR_VAL(func->common.scope->name) : "",
     811           4 :                                                 func->common.scope ? "::" : "",
     812           4 :                                                 ZSTR_VAL(func->common.function_name));
     813           4 :                                         if (EG(current_execute_data) == &dummy_execute_data) {
     814           0 :                                                 EG(current_execute_data) = dummy_execute_data.prev_execute_data;
     815             :                                         }
     816           4 :                                         return FAILURE;
     817             :                                 }
     818             : 
     819         241 :                                 ZVAL_NEW_REF(arg, arg);
     820             :                         }
     821             :                         Z_ADDREF_P(arg);
     822             :                 } else {
     823      483662 :                         if (Z_ISREF_P(arg) &&
     824          76 :                             !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
     825             :                                 /* don't separate references for __call */
     826          76 :                                 arg = Z_REFVAL_P(arg);
     827             :                         }
     828      483586 :                         if (Z_OPT_REFCOUNTED_P(arg)) {
     829             :                                 Z_ADDREF_P(arg);
     830             :                         }
     831             :                 }
     832      483933 :                 param = ZEND_CALL_ARG(call, i+1);
     833      483933 :                 ZVAL_COPY_VALUE(param, arg);
     834             :         }
     835             : 
     836      696085 :         EG(scope) = calling_scope;
     837      696085 :         if (func->common.fn_flags & ZEND_ACC_STATIC) {
     838         382 :                 fci->object = NULL;
     839             :         }
     840      696085 :         Z_OBJ(call->This) = fci->object;
     841             : 
     842      696085 :         if (func->type == ZEND_USER_FUNCTION) {
     843      451276 :                 int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
     844      451276 :                 EG(scope) = func->common.scope;
     845      451276 :                 call->symbol_table = fci->symbol_table;
     846      451276 :                 if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) {
     847             :                         ZEND_ASSERT(GC_TYPE((zend_object*)func->op_array.prototype) == IS_OBJECT);
     848         439 :                         GC_REFCOUNT((zend_object*)func->op_array.prototype)++;
     849         439 :                         ZEND_ADD_CALL_FLAG(call, ZEND_CALL_CLOSURE);
     850             :                 }
     851      451276 :                 if (EXPECTED((func->op_array.fn_flags & ZEND_ACC_GENERATOR) == 0)) {
     852      451274 :                         zend_init_execute_data(call, &func->op_array, fci->retval);
     853      451274 :                         zend_execute_ex(call);
     854             :                 } else {
     855           2 :                         zend_generator_create_zval(call, &func->op_array, fci->retval);
     856             :                 }
     857      451241 :                 if (call_via_handler) {
     858             :                         /* We must re-initialize function again */
     859           7 :                         fci_cache->initialized = 0;
     860             :                 }
     861      244809 :         } else if (func->type == ZEND_INTERNAL_FUNCTION) {
     862      244809 :                 int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
     863      244809 :                 ZVAL_NULL(fci->retval);
     864      244809 :                 if (func->common.scope) {
     865      243796 :                         EG(scope) = func->common.scope;
     866             :                 }
     867      244809 :                 call->prev_execute_data = EG(current_execute_data);
     868      244809 :                 call->return_value = NULL; /* this is not a constructor call */
     869      244809 :                 EG(current_execute_data) = call;
     870      244809 :                 if (EXPECTED(zend_execute_internal == NULL)) {
     871             :                         /* saves one function call if zend_execute_internal is not used */
     872      244809 :                         func->internal_function.handler(call, fci->retval);
     873             :                 } else {
     874           0 :                         zend_execute_internal(call, fci->retval);
     875             :                 }
     876      244800 :                 EG(current_execute_data) = call->prev_execute_data;
     877             :                 zend_vm_stack_free_args(call);
     878             : 
     879             :                 /*  We shouldn't fix bad extensions here,
     880             :                         because it can break proper ones (Bug #34045)
     881             :                 if (!EX(function_state).function->common.return_reference)
     882             :                 {
     883             :                         INIT_PZVAL(f->retval);
     884             :                 }*/
     885      244800 :                 if (EG(exception)) {
     886          82 :                         zval_ptr_dtor(fci->retval);
     887          82 :                         ZVAL_UNDEF(fci->retval);
     888             :                 }
     889             : 
     890      244800 :                 if (call_via_handler) {
     891             :                         /* We must re-initialize function again */
     892           4 :                         fci_cache->initialized = 0;
     893             :                 }
     894             :         } else { /* ZEND_OVERLOADED_FUNCTION */
     895           0 :                 ZVAL_NULL(fci->retval);
     896             : 
     897             :                 /* Not sure what should be done here if it's a static method */
     898           0 :                 if (fci->object) {
     899           0 :                         call->prev_execute_data = EG(current_execute_data);
     900           0 :                         EG(current_execute_data) = call;
     901           0 :                         fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval);
     902           0 :                         EG(current_execute_data) = call->prev_execute_data;
     903             :                 } else {
     904           0 :                         zend_throw_error(NULL, "Cannot call overloaded function for non-object");
     905             :                 }
     906             : 
     907             :                 zend_vm_stack_free_args(call);
     908             : 
     909           0 :                 if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
     910           0 :                         zend_string_release(func->common.function_name);
     911             :                 }
     912           0 :                 efree(func);
     913             : 
     914           0 :                 if (EG(exception)) {
     915           0 :                         zval_ptr_dtor(fci->retval);
     916           0 :                         ZVAL_UNDEF(fci->retval);
     917             :                 }
     918             :         }
     919             : 
     920      696041 :         EG(scope) = orig_scope;
     921             :         zend_vm_stack_free_call_frame(call);
     922             : 
     923      696041 :         if (EG(current_execute_data) == &dummy_execute_data) {
     924      108224 :                 EG(current_execute_data) = dummy_execute_data.prev_execute_data;
     925             :         }
     926             : 
     927      696041 :         if (EG(exception)) {
     928         319 :                 zend_throw_exception_internal(NULL);
     929             :         }
     930      696035 :         return SUCCESS;
     931             : }
     932             : /* }}} */
     933             : 
     934      167961 : ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload) /* {{{ */
     935             : {
     936      167961 :         zend_class_entry *ce = NULL;
     937             :         zval args[1];
     938             :         zval local_retval;
     939             :         int retval;
     940             :         zend_string *lc_name;
     941             :         zend_fcall_info fcall_info;
     942             :         zend_fcall_info_cache fcall_cache;
     943             : 
     944      167961 :         if (key) {
     945       19994 :                 lc_name = Z_STR_P(key);
     946             :         } else {
     947      147967 :                 if (name == NULL || !ZSTR_LEN(name)) {
     948          84 :                         return NULL;
     949             :                 }
     950             : 
     951      147883 :                 if (ZSTR_VAL(name)[0] == '\\') {
     952          18 :                         lc_name = zend_string_alloc(ZSTR_LEN(name) - 1, 0);
     953           9 :                         zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1);
     954             :                 } else {
     955      147874 :                         lc_name = zend_string_tolower(name);
     956             :                 }
     957             :         }
     958             : 
     959      335754 :         ce = zend_hash_find_ptr(EG(class_table), lc_name);
     960      167877 :         if (ce) {
     961      167141 :                 if (!key) {
     962             :                         zend_string_release(lc_name);
     963             :                 }
     964      167141 :                 return ce;
     965             :         }
     966             : 
     967             :         /* The compiler is not-reentrant. Make sure we __autoload() only during run-time
     968             :          * (doesn't impact functionality of __autoload()
     969             :         */
     970         736 :         if (!use_autoload || zend_is_compiling()) {
     971         362 :                 if (!key) {
     972             :                         zend_string_release(lc_name);
     973             :                 }
     974         362 :                 return NULL;
     975             :         }
     976             : 
     977         374 :         if (!EG(autoload_func)) {
     978         436 :                 zend_function *func = zend_hash_str_find_ptr(EG(function_table), ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1);
     979         218 :                 if (func) {
     980          66 :                         EG(autoload_func) = func;
     981             :                 } else {
     982         152 :                         if (!key) {
     983             :                                 zend_string_release(lc_name);
     984             :                         }
     985         152 :                         return NULL;
     986             :                 }
     987             : 
     988             :         }
     989             : 
     990             :         /* Verify class name before passing it to __autoload() */
     991         222 :         if (strspn(ZSTR_VAL(name), "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\") != ZSTR_LEN(name)) {
     992          11 :                 if (!key) {
     993             :                         zend_string_release(lc_name);
     994             :                 }
     995          11 :                 return NULL;
     996             :         }
     997             : 
     998         211 :         if (EG(in_autoload) == NULL) {
     999          89 :                 ALLOC_HASHTABLE(EG(in_autoload));
    1000          89 :                 zend_hash_init(EG(in_autoload), 8, NULL, NULL, 0);
    1001             :         }
    1002             : 
    1003         211 :         if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) {
    1004           4 :                 if (!key) {
    1005             :                         zend_string_release(lc_name);
    1006             :                 }
    1007           4 :                 return NULL;
    1008             :         }
    1009             : 
    1010         207 :         ZVAL_UNDEF(&local_retval);
    1011             : 
    1012         207 :         if (ZSTR_VAL(name)[0] == '\\') {
    1013           2 :                 ZVAL_STRINGL(&args[0], ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1);
    1014             :         } else {
    1015         206 :                 ZVAL_STR_COPY(&args[0], name);
    1016             :         }
    1017             : 
    1018         207 :         fcall_info.size = sizeof(fcall_info);
    1019         207 :         fcall_info.function_table = EG(function_table);
    1020         207 :         ZVAL_STR_COPY(&fcall_info.function_name, EG(autoload_func)->common.function_name);
    1021         207 :         fcall_info.symbol_table = NULL;
    1022         207 :         fcall_info.retval = &local_retval;
    1023         207 :         fcall_info.param_count = 1;
    1024         207 :         fcall_info.params = args;
    1025         207 :         fcall_info.object = NULL;
    1026         207 :         fcall_info.no_separation = 1;
    1027             : 
    1028         207 :         fcall_cache.initialized = 1;
    1029         207 :         fcall_cache.function_handler = EG(autoload_func);
    1030         207 :         fcall_cache.calling_scope = NULL;
    1031         207 :         fcall_cache.called_scope = NULL;
    1032         207 :         fcall_cache.object = NULL;
    1033             : 
    1034         207 :         zend_exception_save();
    1035         207 :         retval = zend_call_function(&fcall_info, &fcall_cache);
    1036         203 :         zend_exception_restore();
    1037             : 
    1038         203 :         zval_ptr_dtor(&args[0]);
    1039             :         zval_dtor(&fcall_info.function_name);
    1040             : 
    1041         203 :         zend_hash_del(EG(in_autoload), lc_name);
    1042             : 
    1043         203 :         zval_ptr_dtor(&local_retval);
    1044             : 
    1045         203 :         if (retval == SUCCESS) {
    1046         406 :                 ce = zend_hash_find_ptr(EG(class_table), lc_name);
    1047             :         }
    1048         203 :         if (!key) {
    1049             :                 zend_string_release(lc_name);
    1050             :         }
    1051         203 :         return ce;
    1052             : }
    1053             : /* }}} */
    1054             : 
    1055      144849 : ZEND_API zend_class_entry *zend_lookup_class(zend_string *name) /* {{{ */
    1056             : {
    1057      144849 :         return zend_lookup_class_ex(name, NULL, 1);
    1058             : }
    1059             : /* }}} */
    1060             : 
    1061       21407 : ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex) /* {{{ */
    1062             : {
    1063       43125 :         while (ex) {
    1064         755 :                 if (ex->called_scope) {
    1065         271 :                         return ex->called_scope;
    1066         484 :                 } else if (ex->func) {
    1067         451 :                         if (ex->func->type != ZEND_INTERNAL_FUNCTION || ex->func->common.scope) {
    1068         173 :                                 return ex->called_scope;
    1069             :                         }
    1070             :                 }
    1071         311 :                 ex = ex->prev_execute_data;
    1072             :         }
    1073       20963 :         return NULL;
    1074             : }
    1075             : /* }}} */
    1076             : 
    1077       21272 : ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */
    1078             : {
    1079       42701 :         while (ex) {
    1080         470 :                 if (Z_OBJ(ex->This)) {
    1081          86 :                         return Z_OBJ(ex->This);
    1082         384 :                 } else if (ex->func) {
    1083         383 :                         if (ex->func->type != ZEND_INTERNAL_FUNCTION || ex->func->common.scope) {
    1084         227 :                                 return Z_OBJ(ex->This);
    1085             :                         }
    1086             :                 }
    1087         157 :                 ex = ex->prev_execute_data;
    1088             :         }
    1089       20959 :         return NULL;
    1090             : }
    1091             : /* }}} */
    1092             : 
    1093         160 : ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name) /* {{{ */
    1094             : {
    1095             :         zval pv;
    1096             :         zend_op_array *new_op_array;
    1097             :         uint32_t original_compiler_options;
    1098             :         int retval;
    1099             : 
    1100         160 :         if (retval_ptr) {
    1101         146 :                 ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 1));
    1102          73 :                 memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
    1103          73 :                 memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len);
    1104          73 :                 Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
    1105          73 :                 Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0';
    1106             :         } else {
    1107         174 :                 ZVAL_STRINGL(&pv, str, str_len);
    1108             :         }
    1109             : 
    1110             :         /*printf("Evaluating '%s'\n", pv.value.str.val);*/
    1111             : 
    1112         160 :         original_compiler_options = CG(compiler_options);
    1113         160 :         CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
    1114         160 :         new_op_array = zend_compile_string(&pv, string_name);
    1115         160 :         CG(compiler_options) = original_compiler_options;
    1116             : 
    1117         160 :         if (new_op_array) {
    1118             :                 zval local_retval;
    1119             : 
    1120         152 :                 EG(no_extensions)=1;
    1121             : 
    1122         152 :                 zend_try {
    1123         152 :                         ZVAL_UNDEF(&local_retval);
    1124         152 :                         zend_execute(new_op_array, &local_retval);
    1125           1 :                 } zend_catch {
    1126           1 :                         destroy_op_array(new_op_array);
    1127           1 :                         efree_size(new_op_array, sizeof(zend_op_array));
    1128           1 :                         zend_bailout();
    1129         151 :                 } zend_end_try();
    1130             : 
    1131         151 :                 if (Z_TYPE(local_retval) != IS_UNDEF) {
    1132         151 :                         if (retval_ptr) {
    1133          67 :                                 ZVAL_COPY_VALUE(retval_ptr, &local_retval);
    1134             :                         } else {
    1135          84 :                                 zval_ptr_dtor(&local_retval);
    1136             :                         }
    1137             :                 } else {
    1138           0 :                         if (retval_ptr) {
    1139           0 :                                 ZVAL_NULL(retval_ptr);
    1140             :                         }
    1141             :                 }
    1142             : 
    1143         151 :                 EG(no_extensions)=0;
    1144         151 :                 destroy_op_array(new_op_array);
    1145         151 :                 efree_size(new_op_array, sizeof(zend_op_array));
    1146         151 :                 retval = SUCCESS;
    1147             :         } else {
    1148           8 :                 retval = FAILURE;
    1149             :         }
    1150             :         zval_dtor(&pv);
    1151         159 :         return retval;
    1152             : }
    1153             : /* }}} */
    1154             : 
    1155           0 : ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name) /* {{{ */
    1156             : {
    1157           0 :         return zend_eval_stringl(str, strlen(str), retval_ptr, string_name);
    1158             : }
    1159             : /* }}} */
    1160             : 
    1161          25 : ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
    1162             : {
    1163             :         int result;
    1164             : 
    1165          25 :         result = zend_eval_stringl(str, str_len, retval_ptr, string_name);
    1166          24 :         if (handle_exceptions && EG(exception)) {
    1167           0 :                 zend_exception_error(EG(exception), E_ERROR);
    1168           0 :                 result = FAILURE;
    1169             :         }
    1170          24 :         return result;
    1171             : }
    1172             : /* }}} */
    1173             : 
    1174          25 : ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
    1175             : {
    1176          25 :         return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions);
    1177             : }
    1178             : /* }}} */
    1179             : 
    1180          13 : ZEND_API void zend_timeout(int dummy) /* {{{ */
    1181             : {
    1182             : 
    1183          13 :         if (zend_on_timeout) {
    1184             : #ifdef ZEND_SIGNALS
    1185             :                 /*
    1186             :                    We got here because we got a timeout signal, so we are in a signal handler
    1187             :                    at this point. However, we want to be able to timeout any user-supplied
    1188             :                    shutdown functions, so pretend we are not in a signal handler while we are
    1189             :                    calling these
    1190             :                 */
    1191             :                 SIGG(running) = 0;
    1192             : #endif
    1193          13 :                 zend_on_timeout(EG(timeout_seconds));
    1194             :         }
    1195             : 
    1196          13 :         zend_error_noreturn(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
    1197             : }
    1198             : /* }}} */
    1199             : 
    1200             : #ifdef ZEND_WIN32
    1201             : VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out)
    1202             : {
    1203             :         zend_bool *php_timed_out;
    1204             : 
    1205             :         /* The doc states it'll be always true, however it theoretically
    1206             :                 could be FALSE when the thread was signaled. */
    1207             :         if (!timed_out) {
    1208             :                 return;
    1209             :         }
    1210             : 
    1211             :         php_timed_out = (zend_bool *)arg;
    1212             :         *php_timed_out = 1;
    1213             : }
    1214             : #endif
    1215             : 
    1216             : /* This one doesn't exists on QNX */
    1217             : #ifndef SIGPROF
    1218             : #define SIGPROF 27
    1219             : #endif
    1220             : 
    1221       21322 : void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
    1222             : {
    1223             : 
    1224       21322 :         EG(timeout_seconds) = seconds;
    1225             : 
    1226             : #ifdef ZEND_WIN32
    1227             :         if(!seconds) {
    1228             :                 return;
    1229             :         }
    1230             : 
    1231             :         /* Don't use ChangeTimerQueueTimer() as it will not restart an expired
    1232             :                 timer, so we could end up with just an ignored timeout. Instead
    1233             :                 delete and recreate. */
    1234             :         if (NULL != tq_timer) {
    1235             :                 if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) {
    1236             :                         EG(timed_out) = 0;
    1237             :                         tq_timer = NULL;
    1238             :                         zend_error_noreturn(E_ERROR, "Could not delete queued timer");
    1239             :                         return;
    1240             :                 }
    1241             :                 tq_timer = NULL;
    1242             :         }
    1243             : 
    1244             :         /* XXX passing NULL means the default timer queue provided by the system is used */
    1245             :         if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)&EG(timed_out), seconds*1000, 0, WT_EXECUTEONLYONCE)) {
    1246             :                 EG(timed_out) = 0;
    1247             :                 tq_timer = NULL;
    1248             :                 zend_error_noreturn(E_ERROR, "Could not queue new timer");
    1249             :                 return;
    1250             :         }
    1251             :         EG(timed_out) = 0;
    1252             : #else
    1253             : #       ifdef HAVE_SETITIMER
    1254             :         {
    1255             :                 struct itimerval t_r;           /* timeout requested */
    1256             :                 int signo;
    1257             : 
    1258       21322 :                 if(seconds) {
    1259         465 :                         t_r.it_value.tv_sec = seconds;
    1260         465 :                         t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
    1261             : 
    1262             : #       ifdef __CYGWIN__
    1263             :                         setitimer(ITIMER_REAL, &t_r, NULL);
    1264             :                 }
    1265             :                 signo = SIGALRM;
    1266             : #       else
    1267         465 :                         setitimer(ITIMER_PROF, &t_r, NULL);
    1268             :                 }
    1269       21322 :                 signo = SIGPROF;
    1270             : #       endif
    1271             : 
    1272       21322 :                 if (reset_signals) {
    1273             : #       ifdef ZEND_SIGNALS
    1274             :                         zend_signal(signo, zend_timeout);
    1275             : #       else
    1276             :                         sigset_t sigset;
    1277             : 
    1278       21267 :                         signal(signo, zend_timeout);
    1279       21267 :                         sigemptyset(&sigset);
    1280       21267 :                         sigaddset(&sigset, signo);
    1281       21267 :                         sigprocmask(SIG_UNBLOCK, &sigset, NULL);
    1282             : #       endif
    1283             :                 }
    1284             :         }
    1285             : #       endif /* HAVE_SETITIMER */
    1286             : #endif
    1287       21322 : }
    1288             : /* }}} */
    1289             : 
    1290       42639 : void zend_unset_timeout(void) /* {{{ */
    1291             : {
    1292             : #ifdef ZEND_WIN32
    1293             :         if (NULL != tq_timer) {
    1294             :                 if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) {
    1295             :                         EG(timed_out) = 0;
    1296             :                         tq_timer = NULL;
    1297             :                         zend_error_noreturn(E_ERROR, "Could not delete queued timer");
    1298             :                         return;
    1299             :                 }
    1300             :                 tq_timer = NULL;
    1301             :         }
    1302             :         EG(timed_out) = 0;
    1303             : #else
    1304             : #       ifdef HAVE_SETITIMER
    1305       42639 :         if (EG(timeout_seconds)) {
    1306             :                 struct itimerval no_timeout;
    1307             : 
    1308         896 :                 no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
    1309             : 
    1310             : #ifdef __CYGWIN__
    1311             :                 setitimer(ITIMER_REAL, &no_timeout, NULL);
    1312             : #else
    1313         896 :                 setitimer(ITIMER_PROF, &no_timeout, NULL);
    1314             : #endif
    1315             :         }
    1316             : #       endif
    1317             : #endif
    1318       42639 : }
    1319             : /* }}} */
    1320             : 
    1321        5707 : zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type) /* {{{ */
    1322             : {
    1323             :         zend_class_entry *ce;
    1324        5707 :         int fetch_sub_type = fetch_type & ZEND_FETCH_CLASS_MASK;
    1325             : 
    1326             : check_fetch_type:
    1327        5718 :         switch (fetch_sub_type) {
    1328             :                 case ZEND_FETCH_CLASS_SELF:
    1329        1623 :                         if (UNEXPECTED(!EG(scope))) {
    1330           0 :                                 zend_throw_or_error(fetch_type, NULL, "Cannot access self:: when no class scope is active");
    1331             :                         }
    1332        1623 :                         return EG(scope);
    1333             :                 case ZEND_FETCH_CLASS_PARENT:
    1334        1359 :                         if (UNEXPECTED(!EG(scope))) {
    1335           0 :                                 zend_throw_or_error(fetch_type, NULL, "Cannot access parent:: when no class scope is active");
    1336           0 :                                 return NULL;
    1337             :                         }
    1338        1359 :                         if (UNEXPECTED(!EG(scope)->parent)) {
    1339           0 :                                 zend_throw_or_error(fetch_type, NULL, "Cannot access parent:: when current class scope has no parent");
    1340             :                         }
    1341        1359 :                         return EG(scope)->parent;
    1342             :                 case ZEND_FETCH_CLASS_STATIC:
    1343         114 :                         ce = zend_get_called_scope(EG(current_execute_data));
    1344         114 :                         if (UNEXPECTED(!ce)) {
    1345           0 :                                 zend_throw_or_error(fetch_type, NULL, "Cannot access static:: when no class scope is active");
    1346           0 :                                 return NULL;
    1347             :                         }
    1348         114 :                         return ce;
    1349             :                 case ZEND_FETCH_CLASS_AUTO: {
    1350        1335 :                                 fetch_sub_type = zend_get_class_fetch_type(class_name);
    1351        1335 :                                 if (UNEXPECTED(fetch_sub_type != ZEND_FETCH_CLASS_DEFAULT)) {
    1352          11 :                                         goto check_fetch_type;
    1353             :                                 }
    1354             :                         }
    1355             :                         break;
    1356             :         }
    1357             : 
    1358        2611 :         if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
    1359        1371 :                 return zend_lookup_class_ex(class_name, NULL, 0);
    1360        1240 :         } else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
    1361          15 :                 if (!(fetch_type & ZEND_FETCH_CLASS_SILENT) && !EG(exception)) {
    1362          12 :                         if (fetch_sub_type == ZEND_FETCH_CLASS_INTERFACE) {
    1363           0 :                                 zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
    1364          12 :                         } else if (fetch_sub_type == ZEND_FETCH_CLASS_TRAIT) {
    1365           0 :                                 zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
    1366             :                         } else {
    1367          12 :                                 zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
    1368             :                         }
    1369             :                 }
    1370           8 :                 return NULL;
    1371             :         }
    1372        1224 :         return ce;
    1373             : }
    1374             : /* }}} */
    1375             : 
    1376       18653 : zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type) /* {{{ */
    1377             : {
    1378             :         zend_class_entry *ce;
    1379             : 
    1380       18653 :         if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
    1381        1126 :                 return zend_lookup_class_ex(class_name, key, 0);
    1382       17527 :         } else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
    1383          31 :                 if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
    1384          21 :                         if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
    1385           2 :                                 zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
    1386          19 :                         } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
    1387           2 :                                 zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
    1388             :                         } else {
    1389          17 :                                 zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
    1390             :                         }
    1391             :                 }
    1392          26 :                 return NULL;
    1393             :         }
    1394       17494 :         return ce;
    1395             : }
    1396             : /* }}} */
    1397             : 
    1398             : #define MAX_ABSTRACT_INFO_CNT 3
    1399             : #define MAX_ABSTRACT_INFO_FMT "%s%s%s%s"
    1400             : #define DISPLAY_ABSTRACT_FN(idx) \
    1401             :         ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : "", \
    1402             :         ai.afn[idx] ? "::" : "", \
    1403             :         ai.afn[idx] ? ZSTR_VAL(ai.afn[idx]->common.function_name) : "", \
    1404             :         ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
    1405             : 
    1406             : typedef struct _zend_abstract_info {
    1407             :         zend_function *afn[MAX_ABSTRACT_INFO_CNT + 1];
    1408             :         int cnt;
    1409             :         int ctor;
    1410             : } zend_abstract_info;
    1411             : 
    1412          43 : static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai) /* {{{ */
    1413             : {
    1414          43 :         if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
    1415          14 :                 if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
    1416          14 :                         ai->afn[ai->cnt] = fn;
    1417             :                 }
    1418          14 :                 if (fn->common.fn_flags & ZEND_ACC_CTOR) {
    1419           1 :                         if (!ai->ctor) {
    1420           1 :                                 ai->cnt++;
    1421           1 :                                 ai->ctor = 1;
    1422             :                         } else {
    1423           0 :                                 ai->afn[ai->cnt] = NULL;
    1424             :                         }
    1425             :                 } else {
    1426          13 :                         ai->cnt++;
    1427             :                 }
    1428             :         }
    1429          43 : }
    1430             : /* }}} */
    1431             : 
    1432     1607021 : void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
    1433             : {
    1434             :         zend_function *func;
    1435             :         zend_abstract_info ai;
    1436             : 
    1437     1607021 :         if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & (ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) {
    1438          23 :                 memset(&ai, 0, sizeof(ai));
    1439             : 
    1440         109 :                 ZEND_HASH_FOREACH_PTR(&ce->function_table, func) {
    1441          43 :                         zend_verify_abstract_class_function(func, &ai);
    1442             :                 } ZEND_HASH_FOREACH_END();
    1443             : 
    1444          23 :                 if (ai.cnt) {
    1445         262 :                         zend_error_noreturn(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
    1446          13 :                                 ZSTR_VAL(ce->name), ai.cnt,
    1447          13 :                                 ai.cnt > 1 ? "s" : "",
    1448         103 :                                 DISPLAY_ABSTRACT_FN(0),
    1449          68 :                                 DISPLAY_ABSTRACT_FN(1),
    1450          65 :                                 DISPLAY_ABSTRACT_FN(2)
    1451             :                                 );
    1452             :                 }
    1453             :         }
    1454     1607008 : }
    1455             : /* }}} */
    1456             : 
    1457         382 : ZEND_API int zend_delete_global_variable(zend_string *name) /* {{{ */
    1458             : {
    1459         382 :     return zend_hash_del_ind(&EG(symbol_table), name);
    1460             : }
    1461             : /* }}} */
    1462             : 
    1463       90372 : ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */
    1464             : {
    1465             :         zend_execute_data *ex;
    1466             :         zend_array *symbol_table;
    1467             : 
    1468             :         /* Search for last called user function */
    1469       90372 :         ex = EG(current_execute_data);
    1470      182866 :         while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->common.type))) {
    1471        2122 :                 ex = ex->prev_execute_data;
    1472             :         }
    1473       90372 :         if (!ex) {
    1474           0 :                 return NULL;
    1475             :         }
    1476       90372 :         if (ex->symbol_table) {
    1477        2523 :                 return ex->symbol_table;
    1478             :         }
    1479             : 
    1480       87849 :         if (EG(symtable_cache_ptr) >= EG(symtable_cache)) {
    1481             :                 /*printf("Cache hit!  Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/
    1482       87564 :                 symbol_table = ex->symbol_table = *(EG(symtable_cache_ptr)--);
    1483       87564 :                 if (!ex->func->op_array.last_var) {
    1484           2 :                         return symbol_table;
    1485             :                 }
    1486       87562 :                 zend_hash_extend(symbol_table, ex->func->op_array.last_var, 0);
    1487             :         } else {
    1488         285 :                 symbol_table = ex->symbol_table = emalloc(sizeof(zend_array));
    1489         285 :                 zend_hash_init(symbol_table, ex->func->op_array.last_var, NULL, ZVAL_PTR_DTOR, 0);
    1490         285 :                 if (!ex->func->op_array.last_var) {
    1491          12 :                         return symbol_table;
    1492             :                 }
    1493         273 :                 zend_hash_real_init(symbol_table, 0);
    1494             :                 /*printf("Cache miss!  Initialized %x\n", EG(active_symbol_table));*/
    1495             :         }
    1496       87835 :         if (EXPECTED(ex->func->op_array.last_var)) {
    1497       87835 :                 zend_string **str = ex->func->op_array.vars;
    1498       87835 :                 zend_string **end = str + ex->func->op_array.last_var;
    1499       87835 :                 zval *var = ZEND_CALL_VAR_NUM(ex, 0);
    1500             : 
    1501             :                 do {
    1502      177191 :                         _zend_hash_append_ind(symbol_table, *str, var);
    1503      177191 :                         str++;
    1504      177191 :                         var++;
    1505      177191 :                 } while (str != end);
    1506             :         }
    1507       87835 :         return symbol_table;
    1508             : }
    1509             : /* }}} */
    1510             : 
    1511       38966 : ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data) /* {{{ */
    1512             : {
    1513       38966 :         zend_op_array *op_array = &execute_data->func->op_array;
    1514       38966 :         HashTable *ht = execute_data->symbol_table;
    1515             : 
    1516             :         /* copy real values from symbol table into CV slots and create
    1517             :            INDIRECT references to CV in symbol table  */
    1518       38966 :         if (EXPECTED(op_array->last_var)) {
    1519       22256 :                 zend_string **str = op_array->vars;
    1520       22256 :                 zend_string **end = str + op_array->last_var;
    1521       22256 :                 zval *var = EX_VAR_NUM(0);
    1522             : 
    1523             :                 do {
    1524      103627 :                         zval *zv = zend_hash_find(ht, *str);
    1525             : 
    1526      103627 :                         if (zv) {
    1527       38517 :                                 if (Z_TYPE_P(zv) == IS_INDIRECT) {
    1528       27810 :                                         zval *val = Z_INDIRECT_P(zv);
    1529             : 
    1530       27810 :                                         ZVAL_COPY_VALUE(var, val);
    1531             :                                 } else {
    1532       10707 :                                         ZVAL_COPY_VALUE(var, zv);
    1533             :                                 }
    1534             :                         } else {
    1535       65110 :                                 ZVAL_UNDEF(var);
    1536       65110 :                                 zv = zend_hash_add_new(ht, *str, var);
    1537             :                         }
    1538      103627 :                         ZVAL_INDIRECT(zv, var);
    1539      103627 :                         str++;
    1540      103627 :                         var++;
    1541      103627 :                 } while (str != end);
    1542             :         }
    1543       38966 : }
    1544             : /* }}} */
    1545             : 
    1546       28688 : ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ */
    1547             : {
    1548       28688 :         zend_op_array *op_array = &execute_data->func->op_array;
    1549       28688 :         HashTable *ht = execute_data->symbol_table;
    1550             : 
    1551             :         /* copy real values from CV slots into symbol table */
    1552       28688 :         if (EXPECTED(op_array->last_var)) {
    1553       16599 :                 zend_string **str = op_array->vars;
    1554       16599 :                 zend_string **end = str + op_array->last_var;
    1555       16599 :                 zval *var = EX_VAR_NUM(0);
    1556             : 
    1557             :                 do {
    1558       74705 :                         if (Z_TYPE_P(var) == IS_UNDEF) {
    1559        7709 :                                 zend_hash_del(ht, *str);
    1560             :                         } else {
    1561       66996 :                                 zend_hash_update(ht, *str, var);
    1562       66996 :                                 ZVAL_UNDEF(var);
    1563             :                         }
    1564       74705 :                         str++;
    1565       74705 :                         var++;
    1566       74705 :                 } while (str != end);
    1567             :         }
    1568       28688 : }
    1569             : /* }}} */
    1570             : 
    1571           0 : ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{{ */
    1572             : {
    1573           0 :         zend_execute_data *execute_data = EG(current_execute_data);
    1574             : 
    1575           0 :         while (execute_data && (!execute_data->func || !ZEND_USER_CODE(execute_data->func->common.type))) {
    1576           0 :                 execute_data = execute_data->prev_execute_data;
    1577             :         }
    1578             : 
    1579           0 :         if (execute_data) {
    1580           0 :                 if (!execute_data->symbol_table) {
    1581           0 :                         zend_ulong h = zend_string_hash_val(name);
    1582           0 :                         zend_op_array *op_array = &execute_data->func->op_array;
    1583             : 
    1584           0 :                         if (EXPECTED(op_array->last_var)) {
    1585           0 :                                 zend_string **str = op_array->vars;
    1586           0 :                                 zend_string **end = str + op_array->last_var;
    1587             : 
    1588             :                                 do {
    1589           0 :                                         if (ZSTR_H(*str) == h &&
    1590           0 :                                             ZSTR_LEN(*str) == ZSTR_LEN(name) &&
    1591           0 :                                             memcmp(ZSTR_VAL(*str), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) {
    1592           0 :                                                 zval *var = EX_VAR_NUM(str - op_array->vars);
    1593           0 :                                                 ZVAL_COPY_VALUE(var, value);
    1594           0 :                                                 return SUCCESS;
    1595             :                                         }
    1596           0 :                                         str++;
    1597           0 :                                 } while (str != end);
    1598             :                         }
    1599           0 :                         if (force) {
    1600           0 :                                 zend_array *symbol_table = zend_rebuild_symbol_table();
    1601           0 :                                 if (symbol_table) {
    1602           0 :                                         return zend_hash_update(symbol_table, name, value) ? SUCCESS : FAILURE;;
    1603             :                                 }
    1604             :                         }
    1605             :                 } else {
    1606           0 :                         return (zend_hash_update_ind(execute_data->symbol_table, name, value) != NULL) ? SUCCESS : FAILURE;
    1607             :                 }
    1608             :         }
    1609           0 :         return FAILURE;
    1610             : }
    1611             : /* }}} */
    1612             : 
    1613       37719 : ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force) /* {{{ */
    1614             : {
    1615       37719 :         zend_execute_data *execute_data = EG(current_execute_data);
    1616             : 
    1617      109669 :         while (execute_data && (!execute_data->func || !ZEND_USER_CODE(execute_data->func->common.type))) {
    1618       34231 :                 execute_data = execute_data->prev_execute_data;
    1619             :         }
    1620             : 
    1621       37719 :         if (execute_data) {
    1622       37711 :                 if (!execute_data->symbol_table) {
    1623        5257 :                         zend_ulong h = zend_hash_func(name, len);
    1624        5257 :                         zend_op_array *op_array = &execute_data->func->op_array;
    1625        5257 :                         if (EXPECTED(op_array->last_var)) {
    1626        5185 :                                 zend_string **str = op_array->vars;
    1627        5185 :                                 zend_string **end = str + op_array->last_var;
    1628             : 
    1629             :                                 do {
    1630       41916 :                                         if (ZSTR_H(*str) == h &&
    1631           2 :                                             ZSTR_LEN(*str) == len &&
    1632           2 :                                             memcmp(ZSTR_VAL(*str), name, len) == 0) {
    1633           2 :                                                 zval *var = EX_VAR_NUM(str - op_array->vars);
    1634           2 :                                                 zval_ptr_dtor(var);
    1635           2 :                                                 ZVAL_COPY_VALUE(var, value);
    1636           2 :                                                 return SUCCESS;
    1637             :                                         }
    1638       41910 :                                         str++;
    1639       41910 :                                 } while (str != end);
    1640             :                         }
    1641        5255 :                         if (force) {
    1642           0 :                                 zend_array *symbol_table = zend_rebuild_symbol_table();
    1643           0 :                                 if (symbol_table) {
    1644           0 :                                         return zend_hash_str_update(symbol_table, name, len, value) ? SUCCESS : FAILURE;;
    1645             :                                 }
    1646             :                         }
    1647             :                 } else {
    1648       32454 :                         return (zend_hash_str_update_ind(execute_data->symbol_table, name, len, value) != NULL) ? SUCCESS : FAILURE;
    1649             :                 }
    1650             :         }
    1651        5263 :         return FAILURE;
    1652             : }
    1653             : /* }}} */
    1654             : 
    1655             : /*
    1656             :  * Local variables:
    1657             :  * tab-width: 4
    1658             :  * c-basic-offset: 4
    1659             :  * indent-tabs-mode: t
    1660             :  * End:
    1661             :  */

Generated by: LCOV version 1.10

Generated at Wed, 02 Sep 2015 17:19:06 +0000 (2 days ago)

Copyright © 2005-2015 The PHP Group
All rights reserved.