]> granicus.if.org Git - php/commitdiff
ported opcache
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 22:23:37 +0000 (00:23 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 22:23:37 +0000 (00:23 +0200)
ext/opcache/Optimizer/zend_optimizer.c
ext/opcache/ZendAccelerator.c
ext/opcache/ZendAccelerator.h
ext/opcache/zend_accelerator_debug.c
ext/opcache/zend_accelerator_hash.c
ext/opcache/zend_accelerator_hash.h
ext/opcache/zend_accelerator_module.c
ext/opcache/zend_accelerator_util_funcs.c
ext/opcache/zend_shared_alloc.c
ext/opcache/zend_shared_alloc.h

index bb41900d2e0f1940a4c71d9369302014cf5bb3da..a4bf4223a7dace501c0718c7c4df5918b373857c 100644 (file)
@@ -61,7 +61,7 @@ static int zend_optimizer_get_collected_constant(HashTable *constants, zval *nam
 static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
 {
        int i = 0;
-       ulong hash_value = STR_HASH_VAL(name);
+       zend_uint_t hash_value = STR_HASH_VAL(name);
 
        while (i < op_array->last_var) {
                if (op_array->vars[i] == name ||
@@ -273,7 +273,7 @@ static void update_op2_const(zend_op_array *op_array,
                        case ZEND_FETCH_DIM_TMP_VAR:
 check_numeric:
                                {
-                                       ulong index;
+                                       zend_uint_t index;
 
                                        if (ZEND_HANDLE_NUMERIC(Z_STR_P(val), index)) {
                                                zval_dtor(val);
index c6a9e1ce43b55507b310b81233f2bc3cd91c821e..b8f9f08b3639305b69cab2859b93e9b5fa3ff089 100644 (file)
@@ -299,7 +299,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
 {
 /* for now interned strings are supported only for non-ZTS build */
 #ifndef ZTS
-       ulong h;
+       zend_uint_t h;
        uint nIndex;
        uint idx;
        Bucket *p;
index 94c467e5fb85c679dc91b843856579c67066ba7a..79f352e5b7131623333267cc48e26eea20c0af7c 100644 (file)
@@ -157,7 +157,7 @@ typedef struct _zend_persistent_script {
        zend_op_array  main_op_array;
        HashTable      function_table;
        HashTable      class_table;
-       long           compiler_halt_offset;   /* position of __HALT_COMPILER or -1 */
+       zend_int_t           compiler_halt_offset;   /* position of __HALT_COMPILER or -1 */
        int            ping_auto_globals_mask; /* which autoglobals are used by the script */
        accel_time_t   timestamp;              /* the script modification time */
        zend_bool      corrupted;
@@ -170,7 +170,7 @@ typedef struct _zend_persistent_script {
         */
        struct zend_persistent_script_dynamic_members {
                time_t       last_used;
-               ulong        hits;
+               zend_uint_t        hits;
                unsigned int memory_consumption;
                unsigned int checksum;
                time_t       revalidate;
@@ -178,12 +178,12 @@ typedef struct _zend_persistent_script {
 } zend_persistent_script;
 
 typedef struct _zend_accel_directives {
-       long           memory_consumption;
-       long           max_accelerated_files;
+       zend_int_t           memory_consumption;
+       zend_int_t           max_accelerated_files;
        double         max_wasted_percentage;
        char          *user_blacklist_filename;
-       long           consistency_checks;
-       long           force_restart_timeout;
+       zend_int_t           consistency_checks;
+       zend_int_t           force_restart_timeout;
        zend_bool      use_cwd;
        zend_bool      ignore_dups;
        zend_bool      validate_timestamps;
@@ -195,18 +195,18 @@ typedef struct _zend_accel_directives {
        zend_bool      file_override_enabled;
        zend_bool      inherited_hack;
        zend_bool      enable_cli;
-       unsigned long  revalidate_freq;
-       unsigned long  file_update_protection;
+       zend_uint_t  revalidate_freq;
+       zend_uint_t  file_update_protection;
        char          *error_log;
 #ifdef ZEND_WIN32
        char          *mmap_base;
 #endif
        char          *memory_model;
-       long           log_verbosity_level;
+       zend_int_t           log_verbosity_level;
 
-       long           optimization_level;
-       long           max_file_size;
-       long           interned_strings_buffer;
+       zend_int_t           optimization_level;
+       zend_int_t           max_file_size;
+       zend_int_t           interned_strings_buffer;
        char          *restrict_api;
 } zend_accel_directives;
 
@@ -240,12 +240,12 @@ typedef struct _zend_accel_globals {
 
 typedef struct _zend_accel_shared_globals {
        /* Cache Data Structures */
-       unsigned long   hits;
-       unsigned long   misses;
-       unsigned long   blacklist_misses;
-       unsigned long   oom_restarts;     /* number of restarts because of out of memory */
-       unsigned long   hash_restarts;    /* number of restarts because of hash overflow */
-       unsigned long   manual_restarts;  /* number of restarts scheduled by opcache_reset() */
+       zend_uint_t   hits;
+       zend_uint_t   misses;
+       zend_uint_t   blacklist_misses;
+       zend_uint_t   oom_restarts;     /* number of restarts because of out of memory */
+       zend_uint_t   hash_restarts;    /* number of restarts because of hash overflow */
+       zend_uint_t   manual_restarts;  /* number of restarts scheduled by opcache_reset() */
        zend_accel_hash hash;             /* hash table for cached scripts */
        zend_accel_hash include_paths;    /* used "include_path" values    */
 
@@ -258,8 +258,8 @@ typedef struct _zend_accel_shared_globals {
        zend_accel_restart_reason restart_reason;
        zend_bool       cache_status_before_restart;
 #ifdef ZEND_WIN32
-    unsigned long   mem_usage;
-    unsigned long   restart_in;
+    zend_uint_t   mem_usage;
+    zend_uint_t   restart_in;
 #endif
        zend_bool       restart_in_progress;
     time_t          revalidate_at;
index d0198dccb3e0ffde93d5008c1d2577c470794205..dd3193a10038e769c1ab96def8f44b692a07c9a4 100644 (file)
@@ -57,7 +57,7 @@ void zend_accel_error(int type, const char *format, ...)
        }
 
 #ifdef ZTS
-    fprintf(fLog, "%s (%lu): ", time_string, (unsigned long)tsrm_thread_id());
+    fprintf(fLog, "%s (" ZEND_UINT_FMT "): ", time_string, (zend_uint_t)tsrm_thread_id());
 #else
     fprintf(fLog, "%s (%d): ", time_string, getpid());
 #endif
index b75377d61bc39b82d294782f4dfb0d231f8a47b9..71dd997b79186ae73bec25d3c7e6e980490fc8d4 100644 (file)
@@ -73,8 +73,8 @@ void zend_accel_hash_init(zend_accel_hash *accel_hash, zend_uint hash_size)
  */
 zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char *key, zend_uint key_length, zend_bool indirect, void *data)
 {
-       zend_ulong hash_value;
-       zend_ulong index;
+       zend_uint_t hash_value;
+       zend_uint_t index;
        zend_accel_hash_entry *entry;
        zend_accel_hash_entry *indirect_bucket = NULL;
 
@@ -142,8 +142,8 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char
  */
 void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
 {
-       zend_ulong hash_value;
-       zend_ulong index;
+       zend_uint_t hash_value;
+       zend_uint_t index;
        zend_accel_hash_entry *entry;
 
        hash_value = zend_inline_hash_func(key, key_length);
@@ -170,8 +170,8 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key
  */
 zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
 {
-       zend_ulong hash_value;
-       zend_ulong index;
+       zend_uint_t hash_value;
+       zend_uint_t index;
        zend_accel_hash_entry *entry;
 
        hash_value = zend_inline_hash_func(key, key_length);
@@ -195,8 +195,8 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, c
 
 int zend_accel_hash_unlink(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
 {
-       zend_ulong hash_value;
-    zend_ulong index;
+    zend_uint_t hash_value;
+    zend_uint_t index;
     zend_accel_hash_entry *entry, *last_entry=NULL;
 
        hash_value = zend_inline_hash_func(key, key_length);
index 2de28bffa7320806597a4d886c5848200a7aa686..99e92cd194fd00e43c77b4bf02635b9ea66b7fc6 100644 (file)
@@ -45,7 +45,7 @@
 typedef struct _zend_accel_hash_entry zend_accel_hash_entry;
 
 struct _zend_accel_hash_entry {
-       zend_ulong             hash_value;
+       zend_uint_t             hash_value;
        char                  *key;
        zend_uint              key_length;
        zend_accel_hash_entry *next;
index da2c04fdf799eb83fbd2dab66f69c3dd71eebe3b..f6581c1ba6eafd01abe222d0cbbabee73a6f96ad 100644 (file)
@@ -100,8 +100,8 @@ static int validate_api_restriction(TSRMLS_D)
 
 static ZEND_INI_MH(OnUpdateMemoryConsumption)
 {
-       long *p;
-       long memsize;
+       php_int_t *p;
+       php_int_t memsize;
 #ifndef ZTS
        char *base = (char *) mh_arg2;
 #else
@@ -111,7 +111,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
        /* keep the compiler happy */
        (void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
 
-       p = (long *) (base + (size_t)mh_arg1);
+       p = (php_int_t *) (base + (size_t)mh_arg1);
        memsize = atoi(new_value);
        /* sanity check we must use at least 8 MB */
        if (memsize < 8) {
@@ -137,8 +137,8 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
 
 static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
 {
-       long *p;
-       long size;
+       php_int_t *p;
+       php_int_t size;
 #ifndef ZTS
        char *base = (char *) mh_arg2;
 #else
@@ -148,7 +148,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
        /* keep the compiler happy */
        (void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
 
-       p = (long *) (base + (size_t)mh_arg1);
+       p = (php_int_t *) (base + (size_t)mh_arg1);
        size = atoi(new_value);
        /* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */
 
@@ -183,7 +183,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
 static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
 {
        double *p;
-       long percentage;
+       php_int_t percentage;
 #ifndef ZTS
        char *base = (char *) mh_arg2;
 #else
@@ -407,33 +407,33 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
                        char buf[32];
                        php_info_print_table_row(2, "Startup", "OK");
                        php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
-                       snprintf(buf, sizeof(buf), "%ld", ZCSG(hits));
+                       snprintf(buf, sizeof(buf), ZEND_UINT_FMT, ZCSG(hits));
                        php_info_print_table_row(2, "Cache hits", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
+                       snprintf(buf, sizeof(buf), "%pd", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
                        php_info_print_table_row(2, "Cache misses", buf);
                        snprintf(buf, sizeof(buf), "%ld", ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
                        php_info_print_table_row(2, "Used memory", buf);
-                       snprintf(buf, sizeof(buf), "%ld", zend_shared_alloc_get_free_memory());
+                       snprintf(buf, sizeof(buf), "%pd", zend_shared_alloc_get_free_memory());
                        php_info_print_table_row(2, "Free memory", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZSMMG(wasted_shared_memory));
+                       snprintf(buf, sizeof(buf), "%pd", ZSMMG(wasted_shared_memory));
                        php_info_print_table_row(2, "Wasted memory", buf);
                        if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) {
-                               snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
+                               snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
                                php_info_print_table_row(2, "Interned Strings Used memory", buf);
-                               snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
+                               snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
                                php_info_print_table_row(2, "Interned Strings Free memory", buf);
                        }
                        snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_direct_entries);
                        php_info_print_table_row(2, "Cached scripts", buf);
                        snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_entries);
                        php_info_print_table_row(2, "Cached keys", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).max_num_entries);
+                       snprintf(buf, sizeof(buf), "%pd", ZCSG(hash).max_num_entries);
                        php_info_print_table_row(2, "Max keys", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZCSG(oom_restarts));
+                       snprintf(buf, sizeof(buf), "%pd", ZCSG(oom_restarts));
                        php_info_print_table_row(2, "OOM restarts", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZCSG(hash_restarts));
+                       snprintf(buf, sizeof(buf), "%pd", ZCSG(hash_restarts));
                        php_info_print_table_row(2, "Hash keys restarts", buf);
-                       snprintf(buf, sizeof(buf), "%ld", ZCSG(manual_restarts));
+                       snprintf(buf, sizeof(buf), "%pd", ZCSG(manual_restarts));
                        php_info_print_table_row(2, "Manual restarts", buf);
                }
        }
@@ -497,7 +497,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
                        add_assoc_stringl(&persistent_script_report, "last_used", str, len);
                        add_assoc_int(&persistent_script_report, "last_used_timestamp", script->dynamic_members.last_used);
                        if (ZCG(accel_directives).validate_timestamps) {
-                               add_assoc_int(&persistent_script_report, "timestamp", (long)script->timestamp);
+                               add_assoc_int(&persistent_script_report, "timestamp", (zend_int_t)script->timestamp);
                        }
                        timerclear(&exec_time);
                        timerclear(&fetch_time);
@@ -514,7 +514,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
    Obtain statistics information regarding code acceleration */
 static ZEND_FUNCTION(opcache_get_status)
 {
-       long reqs;
+       zend_int_t reqs;
        zval memory_usage, statistics, scripts;
        zend_bool fetch_scripts = 1;
 
index 345393f946415164691f87b45073e3bad65dac17..c6534ca6c16395edf25c12f15adea7d81c3d3280 100644 (file)
 
 static zend_uint zend_accel_refcount = ZEND_PROTECTED_REFCOUNT;
 
-#if SIZEOF_SIZE_T <= SIZEOF_ZEND_INT || defined PHP_WIN32
+#if SIZEOF_SIZE_T <= SIZEOF_ZEND_INT
 /* If sizeof(void*) == sizeof(ulong) we can use zend_hash index functions */
-# define accel_xlat_set(old, new)      zend_hash_index_update_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old), (new))
-# define accel_xlat_get(old)           zend_hash_index_find_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old))
+# define accel_xlat_set(old, new)      zend_hash_index_update_ptr(&ZCG(bind_hash), (zend_uint_t)(zend_uintptr_t)(old), (new))
+# define accel_xlat_get(old)           zend_hash_index_find_ptr(&ZCG(bind_hash), (zend_uint_t)(zend_uintptr_t)(old))
 #else
-# define accel_xlat_set(old, new)      (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new))
-# define accel_xlat_get(old, new)      ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new)))
+# define accel_xlat_set(old, new)      (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_uint_t)(zend_uintptr_t)(old), (void**)&(new))
+# define accel_xlat_get(old, new)      ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_uint_t)(zend_uintptr_t)(old), (void**)&(new)))
 #endif
 
 typedef int (*id_function_t)(void *, void *);
@@ -333,7 +333,7 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
 {
        uint idx;
        Bucket *p, *q, *r;
-       ulong nIndex;
+       zend_uint_t nIndex;
        TSRMLS_FETCH();
 
        ht->nTableSize = source->nTableSize;
@@ -412,7 +412,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
 {
        uint idx;
        Bucket *p, *q;
-       ulong nIndex;
+       zend_uint_t nIndex;
        zend_class_entry *new_ce;
        zend_function *new_prototype;
        zend_op_array *new_entry;
@@ -490,7 +490,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
 {
        uint idx;
        Bucket *p, *q;
-       ulong nIndex;
+       zend_uint_t nIndex;
        zend_class_entry *new_ce;
        zend_property_info *prop_info;
 
index 0faabee8b276c89efc4eaa21fe3c043b9cdecd8c..8a60d757366cf5da8c060146d7e402bd379244e5 100644 (file)
@@ -288,7 +288,7 @@ static size_t zend_shared_alloc_get_largest_free_block(void)
 #define MIN_FREE_MEMORY 64*1024
 
 #define SHARED_ALLOC_FAILED() do {             \
-               zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %ld bytes (%ld bytes free)", (long)size, (long)ZSMMG(shared_free)); \
+               zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %pd bytes (%pd bytes free)", (zend_int_t)size, (zend_int_t)ZSMMG(shared_free)); \
                if (zend_shared_alloc_get_largest_free_block() < MIN_FREE_MEMORY) { \
                        ZSMMG(memory_exhausted) = 1; \
                } \
@@ -327,7 +327,7 @@ int zend_shared_memdup_size(void *source, size_t size)
 {
        void *old_p;
 
-       if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+       if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)source)) != NULL) {
                /* we already duplicated this pointer */
                return 0;
        }
@@ -339,7 +339,7 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML
 {
        void *old_p, *retval;
 
-       if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+       if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)source)) != NULL) {
                /* we already duplicated this pointer */
                return old_p;
        }
@@ -431,14 +431,14 @@ void zend_shared_alloc_clear_xlat_table(void)
 
 void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
 {
-       zend_hash_index_update_ptr(&xlat_table, (ulong)old, (void*)new);
+       zend_hash_index_update_ptr(&xlat_table, (zend_uint_t)old, (void*)new);
 }
 
 void *zend_shared_alloc_get_xlat_entry(const void *old)
 {
        void *retval;
 
-       if ((retval = zend_hash_index_find_ptr(&xlat_table, (ulong)old)) == NULL) {
+       if ((retval = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)old)) == NULL) {
                return NULL;
        }
        return retval;
index 57ea8d3fdd4c3388939c38b7fe55de9f17c14598..b16b1a30dd11256eccb3abeb2ca82c4e765f0c91 100644 (file)
@@ -130,7 +130,7 @@ int  zend_shared_memdup_size(void *p, size_t size);
 typedef union _align_test {
        void   *ptr;
        double  dbl;
-       long    lng;
+       zend_int_t  lng;
 } align_test;
 
 #if ZEND_GCC_VERSION >= 2000