]> granicus.if.org Git - php/commitdiff
Replace fast_call_user_function() with zend_call_function()
authorZeev Suraski <zeev@php.net>
Tue, 5 Aug 2003 10:29:03 +0000 (10:29 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 5 Aug 2003 10:29:03 +0000 (10:29 +0000)
ext/curl/interface.c
ext/curl/php_curl.h
ext/standard/array.c
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/xml/xml.c

index 0f46ec28a919c64a60b5ed1727df668fdd9762e1..feec10b1ffbb72cffa4933b2acf5dc891be08e7d 100644 (file)
@@ -403,6 +403,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
                        zval *handle = NULL;
                        zval *zdata = NULL;
                        int   error;
+                       zend_fcall_info fci;
 
                        MAKE_STD_ZVAL(handle);
                        ZVAL_RESOURCE(handle, ch->id);
@@ -413,7 +414,17 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
                        ZVAL_STRINGL(zdata, data, length, 1);
                        argv[1] = &zdata;
 
-                       error = fast_call_user_function(EG(function_table), NULL, t->func_name, &retval_ptr, 2, argv, 0, NULL, &t->func_ptr TSRMLS_CC);
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.object_pp = NULL;
+                       fci.function_name = t->func_name;
+                       fci.retval_ptr_ptr = &retval_ptr;
+                       fci.param_count = 2;
+                       fci.params = argv;
+                       fci.no_separation = 0;
+                       fci.symbol_table = NULL;
+
+                       error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC);
                        if (error == FAILURE) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION");
                                length = -1;
@@ -454,6 +465,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
                        zval  *retval_ptr;
                        int   length;
                        int   error;
+                       zend_fcall_info fci;
                        TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
 
                        MAKE_STD_ZVAL(handle);
@@ -470,7 +482,17 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
                        argv[1] = &zfd;
                        argv[2] = &zlength;
 
-                       error = fast_call_user_function(EG(function_table), NULL, t->func_name, &retval_ptr, 3, argv, 0, NULL, &t->func_ptr TSRMLS_CC);
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = t->func_name;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &retval_ptr;
+                       fci.param_count = 3;
+                       fci.params = argv;
+                       fci.no_separation = 0;
+                       fci.symbol_table = NULL;
+
+                       error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC);
                        if (error == FAILURE) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_READFUNCTION"); 
                                length = -1;
@@ -518,6 +540,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
                        zval  *zdata = NULL;
                        zval  *retval_ptr;
                        int   error;
+                       zend_fcall_info fci;
 
                        MAKE_STD_ZVAL(handle);
                        MAKE_STD_ZVAL(zdata);
@@ -528,8 +551,18 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
 
                        argv[0] = &handle;
                        argv[1] = &zdata;
-                       
-                       error = fast_call_user_function(EG(function_table), NULL, t->func_name, &retval_ptr, 2, argv, 0, NULL, &t->func_ptr TSRMLS_CC);
+
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = t->func_name;
+                       fci.symbol_table = NULL;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &retval_ptr;
+                       fci.param_count = 2;
+                       fci.params = argv;
+                       fci.no_separation = 0;
+
+                       error = zend_call_user_function(&fci, &t->fci_cache TSRMLS_CC);
                        if (error == FAILURE) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the CURLOPT_HEADERFUNCTION");
                                length = -1;
@@ -894,7 +927,7 @@ PHP_FUNCTION(curl_setopt)
                case CURLOPT_WRITEFUNCTION:
                        if (ch->handlers->write->func_name) {
                                zval_ptr_dtor(&ch->handlers->write->func_name);
-                               ch->handlers->write->func_ptr = NULL;
+                               ch->handlers->write->fci_cache = empty_fcall_info_cache;
                        }
                        zval_add_ref(zvalue);
                        ch->handlers->write->func_name = *zvalue;
@@ -903,7 +936,7 @@ PHP_FUNCTION(curl_setopt)
                case CURLOPT_READFUNCTION:
                        if (ch->handlers->read->func_name) {
                                zval_ptr_dtor(&ch->handlers->read->func_name);
-                               ch->handlers->write->func_ptr = NULL;
+                               ch->handlers->write->fci_cache = empty_fcall_info_cache;
                        }
                        zval_add_ref(zvalue);
                        ch->handlers->read->func_name = *zvalue;
@@ -912,7 +945,7 @@ PHP_FUNCTION(curl_setopt)
                case CURLOPT_HEADERFUNCTION:
                        if (ch->handlers->write_header->func_name) {
                                zval_ptr_dtor(&ch->handlers->write_header->func_name);
-                               ch->handlers->write->func_ptr = NULL;
+                               ch->handlers->write->fci_cache = empty_fcall_info_cache;
                        }
                        zval_add_ref(zvalue);
                        ch->handlers->write_header->func_name = *zvalue;
index bd4f20aaa919d08cb7770db0126aedd1221d769f..46d5509a50bf6fb2e081f7cbf43f8c18ed5284cf 100644 (file)
@@ -78,20 +78,20 @@ PHP_FUNCTION(curl_multi_close);
 void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
 
 typedef struct {
-       zval          *func_name;
-       zend_function *func_ptr;
-       FILE          *fp;
-       smart_str      buf;
-       int            method;
-       int            type;
+       zval            *func_name;
+       zend_fcall_info fci_cache;
+       FILE            *fp;
+       smart_str       buf;
+       int             method;
+       int             type;
 } php_curl_write;
 
 typedef struct {
-       zval          *func_name;
-       zend_function *func_ptr;
-       FILE          *fp;
-       long           fd;
-       int            method;
+       zval            *func_name;
+       zend_fcall_info fci_cache;
+       FILE            *fp;
+       long            fd;
+       int             method;
 } php_curl_read;
 
 typedef struct {
index 28257184614b0e819bbe285c920dfefaa1f912d1..8020d468b11a568d089c5416bd5f80eacf522793 100644 (file)
@@ -523,6 +523,7 @@ static int array_user_compare(const void *a, const void *b TSRMLS_DC)
        Bucket *s;
        zval **args[2];
        zval *retval_ptr;
+       zend_fcall_info fci;
 
        f = *((Bucket **) a);
        s = *((Bucket **) b);
@@ -530,7 +531,17 @@ static int array_user_compare(const void *a, const void *b TSRMLS_DC)
        args[0] = (zval **) f->pData;
        args[1] = (zval **) s->pData;
 
-       if (fast_call_user_function(EG(function_table), NULL, *BG(user_compare_func_name), &retval_ptr, 2, args, 0, NULL, &BG(user_compare_func_ptr) TSRMLS_CC)== SUCCESS
+       fci.size = sizeof(fci);
+       fci.function_table = EG(function_table);
+       fci.function_name = *BG(user_compare_func_name);
+       fci.symbol_table = NULL;
+       fci.object_pp = NULL;
+       fci.retval_ptr_ptr = &retval_ptr;
+       fci.param_count = 2;
+       fci.params = args;
+       fci.no_separation = 0;
+
+       if (zend_call_function(&fci, &BG(user_compare_fci_cache) TSRMLS_CC)== SUCCESS
                && retval_ptr) {
                long retval;
 
@@ -552,7 +563,7 @@ PHP_FUNCTION(usort)
        HashTable *target_hash;
 
        old_compare_func = BG(user_compare_func_name);
-       BG(user_compare_func_ptr) = NULL;
+       BG(user_compare_fci_cache) = empty_fcall_info_cache;
 
        if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &array, &BG(user_compare_func_name)) == FAILURE) {
                BG(user_compare_func_name) = old_compare_func;
@@ -582,7 +593,7 @@ PHP_FUNCTION(uasort)
        HashTable *target_hash;
 
        old_compare_func = BG(user_compare_func_name);
-       BG(user_compare_func_ptr) = NULL;
+       BG(user_compare_fci_cache) = empty_fcall_info_cache;
        if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &array, &BG(user_compare_func_name)) == FAILURE) {
                BG(user_compare_func_name) = old_compare_func;
                WRONG_PARAM_COUNT;
@@ -975,6 +986,8 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
                        }
                        php_array_walk(thash, userdata, recursive TSRMLS_CC);
                } else {
+                       zend_fcall_info fci;
+
                        /* Allocate space for key */
                        MAKE_STD_ZVAL(key);
 
@@ -985,11 +998,19 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
                        } else {
                                ZVAL_STRINGL(key, string_key, string_key_len-1, 1);
                        }
-               
+
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = *BG(array_walk_func_name);
+                       fci.symbol_table = NULL;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &retval_ptr;
+                       fci.param_count = userdata ? 3 : 2;
+                       fci.params = args;
+                       fci.no_separation = 0;
+
                        /* Call the userland function */
-                       if (fast_call_user_function(EG(function_table), NULL, *BG(array_walk_func_name),
-                                                          &retval_ptr, userdata ? 3 : 2, args, 0, NULL, &BG(array_walk_func_ptr) TSRMLS_CC) == SUCCESS) {
-               
+                       if (zend_call_function(&fci, &BG(array_walk_fci_cache) TSRMLS_CC) == SUCCESS) {
                                zval_ptr_dtor(&retval_ptr);
                        } else {
                                char *func_name;
@@ -1023,7 +1044,7 @@ PHP_FUNCTION(array_walk)
        HashTable *target_hash;
 
        argc = ZEND_NUM_ARGS();
-       BG(array_walk_func_ptr) = NULL;
+       BG(array_walk_fci_cache) = empty_fcall_info_cache;
        old_walk_func_name = BG(array_walk_func_name);
        if (argc < 2 || argc > 3 ||
                zend_get_parameters_ex(argc, &array, &BG(array_walk_func_name), &userdata) == FAILURE) {
@@ -3329,7 +3350,7 @@ PHP_FUNCTION(array_reduce)
        zval **operand;
        zval *result = NULL;
        zval *retval;
-       zend_function *func_ptr = NULL;
+       zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
        char *callback_name;
        HashPosition pos;
        HashTable *htbl;
@@ -3373,9 +3394,22 @@ PHP_FUNCTION(array_reduce)
        zend_hash_internal_pointer_reset_ex(htbl, &pos);
        while (zend_hash_get_current_data_ex(htbl, (void **)&operand, &pos) == SUCCESS) {
                if (result) {
+                       zend_fcall_info fci;
+
                        args[0] = &result;
                        args[1] = operand;
-                       if (fast_call_user_function(EG(function_table), NULL, *callback, &retval, 2, args, 0, NULL, &func_ptr TSRMLS_CC) == SUCCESS && retval) {
+
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = *callback;
+                       fci.symbol_table = NULL;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &retval;
+                       fci.param_count = 2;
+                       fci.params = args;
+                       fci.no_separation = 0;
+
+                       if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && retval) {
                                zval_ptr_dtor(&result);
                                result = retval;
                        } else {
@@ -3407,7 +3441,7 @@ PHP_FUNCTION(array_filter)
        zval *retval = NULL;
        char *callback_name;
        char *string_key;
-       zend_function *func_ptr = NULL;
+       zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
        uint string_key_len;
        ulong num_key;
        HashPosition pos;
@@ -3441,8 +3475,21 @@ PHP_FUNCTION(array_filter)
                 zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos)) {
 
                if (callback) {
+                       zend_fcall_info fci;
+
                        args[0] = operand;
-                       if (fast_call_user_function(EG(function_table), NULL, *callback, &retval, 1, args, 0, NULL, &func_ptr TSRMLS_CC) == SUCCESS && retval) {
+
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = *callback;
+                       fci.symbol_table = NULL;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &retval;
+                       fci.param_count = 1;
+                       fci.params = args;
+                       fci.no_separation = 0;
+
+                       if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && retval) {
                                if (!zend_is_true(retval)) {
                                        zval_ptr_dtor(&retval);
                                        continue;
@@ -3483,7 +3530,7 @@ PHP_FUNCTION(array_map)
        HashPosition *array_pos;
        zval **args;
        char *callback_name;
-       zend_function *func_ptr = NULL;
+       zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
        int i, k, maxlen = 0;
        int *array_len;
 
@@ -3593,7 +3640,19 @@ PHP_FUNCTION(array_map)
                }
 
                if (Z_TYPE_P(callback) != IS_NULL) {
-                       if (!fast_call_user_function(EG(function_table), NULL, callback, &result, ZEND_NUM_ARGS() - 1, &params[1], 0, NULL, &func_ptr TSRMLS_CC) == SUCCESS && result) {
+                       zend_fcall_info fci;
+
+                       fci.size = sizeof(fci);
+                       fci.function_table = EG(function_table);
+                       fci.function_name = callback;
+                       fci.symbol_table = NULL;
+                       fci.object_pp = NULL;
+                       fci.retval_ptr_ptr = &result;
+                       fci.param_count = ZEND_NUM_ARGS()-1;
+                       fci.params = &params[1];
+                       fci.no_separation = 0;
+
+                       if (!zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && result) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the map callback");
                                efree(array_len);
                                efree(args);
index 5354e168587813f27e52edd5dc22397f558ae380..a6c380428e1d0890260e155fb1fd44d37c7e86be 100644 (file)
@@ -1024,8 +1024,8 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p TSRMLS_DC)
        BG(left) = -1;
        BG(user_tick_functions) = NULL;
        BG(user_filter_map) = NULL;
-       BG(user_compare_func_ptr) = NULL;
-       BG(array_walk_func_ptr) = NULL;
+       BG(user_compare_fci_cache) = empty_fcall_info_cache;
+       /*BG(array_walk_fci_cache) = empty_fcall_info_cache;*/
        zend_hash_init(&BG(sm_protected_env_vars), 5, NULL, NULL, 1);
        BG(sm_allowed_env_vars) = NULL;
 
index 19b07c086d9329d74302fae684539b9f663f2e2c..4d60602366d8ab9e738589a5d8dacad7daf6831d 100644 (file)
@@ -137,7 +137,7 @@ typedef signed int php_int32;
 
 #define MT_N (624)
 
-typedef struct {
+typedef struct _php_basic_globals {
        HashTable *user_shutdown_function_names;
        HashTable putenv_ht;
        zval *strtok_zval;
@@ -148,9 +148,9 @@ typedef struct {
        ulong strtok_len;
        char str_ebuf[40];
        zval **array_walk_func_name;
-       zend_function *array_walk_func_ptr;
+       zend_fcall_info_cache array_walk_fci_cache;
        zval **user_compare_func_name;
-       zend_function *user_compare_func_ptr;
+       zend_fcall_info_cache user_compare_fci_cache;
        zend_llist *user_tick_functions;
 
        zval *active_ini_file_section;
index 2504a94460b497436155b6da0c3607c72cfa549e..ef6f762ea4d6d5fd5ccde3a8be559ea0ec9e94d2 100644 (file)
@@ -406,13 +406,25 @@ static zval *xml_call_handler(xml_parser *parser, zval *handler, zend_function *
                zval *retval;
                int i;  
                int result;
+               zend_fcall_info fci;
 
                args = emalloc(sizeof(zval **) * argc);
                for (i = 0; i < argc; i++) {
                        args[i] = &argv[i];
                }
                
-               result = fast_call_user_function(EG(function_table), &parser->object, handler, &retval, argc, args, 0, NULL, &function_ptr TSRMLS_CC);
+               fci.size = sizeof(fci);
+               fci.function_table = EG(function_table);
+               fci.function_name = handler;
+               fci.symbol_table = NULL;
+               fci.object_pp = &parser->object;
+               fci.retval_ptr_ptr = &retval;
+               fci.param_count = argc;
+               fci.params = args;
+               fci.no_separation = 0;
+               /*fci.function_handler_cache = &function_ptr;*/
+
+               result = zend_call_function(&fci, NULL TSRMLS_CC);
                if (result == FAILURE) {
                        zval **method;
                        zval **obj;