Changeset 1560 in svn


Ignore:
Timestamp:
2014-11-10T09:07:27Z (4 years ago)
Author:
Xuefer
Message:

support for autoload in xcache_get

Location:
trunk
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.frag.deps

    r1558 r1560  
    11$(XCACHE_INCLUDES_I) includes.lo $(builddir)/includes.lo: $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
    22mod_assembler/xc_assembler.lo $(builddir)/mod_assembler/xc_assembler.lo:
    3 mod_cacher/xc_cacher.lo $(builddir)/mod_cacher/xc_cacher.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
     3mod_cacher/xc_cacher.lo $(builddir)/mod_cacher/xc_cacher.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    44mod_coverager/xc_coverager.lo $(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    55mod_decoder/xc_decoder.lo $(builddir)/mod_decoder/xc_decoder.lo:
    6 mod_disassembler/xc_disassembler.lo $(builddir)/mod_disassembler/xc_disassembler.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
     6mod_disassembler/xc_disassembler.lo $(builddir)/mod_disassembler/xc_disassembler.lo: $(XCACHE_PROC_H) $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h
    77mod_encoder/xc_encoder.lo $(builddir)/mod_encoder/xc_encoder.lo:
    8 mod_optimizer/xc_optimizer.lo $(builddir)/mod_optimizer/xc_optimizer.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
     8mod_optimizer/xc_optimizer.lo $(builddir)/mod_optimizer/xc_optimizer.lo: $(XCACHE_PROC_H) $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    99util/xc_trace.lo $(builddir)/util/xc_trace.lo: $(srcdir)/util/xc_trace.h
    1010util/xc_vector_test.lo $(builddir)/util/xc_vector_test.lo: $(srcdir)/util/xc_vector.h
    11 xcache.lo $(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
     11xcache.lo $(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_extension.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    1212xcache/xc_allocator.lo $(builddir)/xcache/xc_allocator.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
    1313xcache/xc_allocator_bestfit.lo $(builddir)/xcache/xc_allocator_bestfit.lo: $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h
     
    1919xcache/xc_mutex.lo $(builddir)/xcache/xc_mutex.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
    2020xcache/xc_opcode_spec.lo $(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_opcode_spec_def.h $(srcdir)/xcache/xc_shm.h
    21 xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/processor/class-helper.h $(srcdir)/processor/debug.h $(srcdir)/processor/processor-t.h $(srcdir)/processor/string-helper-t.h $(srcdir)/processor/string-helper.h $(srcdir)/processor/types.h $(srcdir)/processor/var-helper-t.h $(srcdir)/processor/var-helper.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_util.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
     21xcache/xc_processor.lo $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/util/xc_align.h $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    2222xcache/xc_sandbox.lo $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/util/xc_vector.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h
    2323xcache/xc_shm.lo $(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_mutex.h $(srcdir)/xcache/xc_shm.h
  • trunk/mod_cacher/xc_cacher.c

    r1558 r1560  
    33203320    xc_entry_var_t entry_var, *stored_entry_var;
    33213321    zval *name;
     3322    xc_vector_t index_to_ce = xc_vector_initializer(zend_class_entry *, 0);
     3323    xc_vector_t pending_class_names = xc_vector_initializer(xc_constant_string_t, 0);
     3324    zend_bool reload_class;
    33223325    VAR_BUFFER_FLAGS(name);
    33233326
     
    33393342    }
    33403343
    3341     ENTER_LOCK(cache) {
    3342         stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC);
    3343         if (stored_entry_var) {
    3344             /* return */
    3345             xc_processor_restore_var(return_value, stored_entry_var TSRMLS_CC);
     3344    do {
     3345        reload_class = 0;
     3346        if (xc_vector_size(&pending_class_names)) {
     3347            size_t i, end = xc_vector_size(&pending_class_names);
     3348            assert(end != 0);
     3349            for (i = 0; i < end; ++i) {
     3350                xc_constant_string_t *pending_class_name = &xc_vector_data(xc_constant_string_t, &pending_class_names)[i];
     3351                zend_class_entry *ce = xc_lookup_class(pending_class_name->str, pending_class_name->len, 1 TSRMLS_CC);
     3352                if (!ce) {
     3353                    php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s not found when restroing variable", pending_class_name->str);
     3354                    break;
     3355                }
     3356            }
     3357            if (i != end) {
     3358                break;
     3359            }
     3360            xc_vector_clear(&pending_class_names);
     3361        }
     3362
     3363        ENTER_LOCK(cache) {
     3364            stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC);
     3365            if (!stored_entry_var) {
     3366                RETVAL_NULL();
     3367                break;
     3368            }
     3369
     3370            if (stored_entry_var->class_names_count) {
     3371                zend_uint i;
     3372                /* see if lucky to have all classes needed already loaded */
     3373                for (i = 0; i < stored_entry_var->class_names_count; ++i) {
     3374                    xc_constant_string_t *class_name = &stored_entry_var->class_names[i];
     3375                    zend_class_entry *ce = xc_lookup_class(class_name->str, class_name->len, 0 TSRMLS_CC);
     3376
     3377                    /* not found, add to pending */
     3378                    if (!ce) {
     3379                        xc_constant_string_t pending_class_name;
     3380                        pending_class_name.str = estrndup(class_name->str, class_name->len);
     3381                        pending_class_name.len = class_name->len;
     3382                        xc_vector_push_back(&pending_class_names, &pending_class_name);
     3383                        reload_class = 1;
     3384                    }
     3385                    else if (!reload_class) {
     3386                        xc_vector_push_back(&index_to_ce, &ce);
     3387                    }
     3388                }
     3389
     3390                if (reload_class) {
     3391                    /* not all loaded, load it after unload and run another pass */
     3392                    xc_vector_clear(&index_to_ce);
     3393                    break;
     3394                }
     3395            }
     3396
     3397            xc_processor_restore_var(return_value, stored_entry_var, xc_vector_data(zend_class_entry *, &index_to_ce) TSRMLS_CC);
    33463398            xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
    3347         }
    3348         else {
    3349             RETVAL_NULL();
    3350         }
    3351     } LEAVE_LOCK(cache);
     3399        } LEAVE_LOCK(cache);
     3400    } while (reload_class);
     3401
     3402    if (xc_vector_size(&pending_class_names)) {
     3403        size_t i;
     3404        for (i = 0; i < xc_vector_size(&pending_class_names); ++i) {
     3405            efree(xc_vector_data(xc_constant_string_t, &pending_class_names)[i].str);
     3406        }
     3407    }
     3408    xc_vector_destroy(&pending_class_names);
     3409    xc_vector_destroy(&index_to_ce);
     3410
    33523411    VAR_BUFFER_FREE(name);
    33533412}
     
    36163675            }
    36173676            else {
    3618                 xc_processor_restore_var(&oldzval, stored_entry_var TSRMLS_CC);
     3677                xc_processor_restore_var(&oldzval, stored_entry_var, NULL TSRMLS_CC);
    36193678                convert_to_long(&oldzval);
    36203679                value = Z_LVAL(oldzval);
  • trunk/processor/foot.m4

    r1558 r1560  
    119119}
    120120dnl }}}
    121 EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_t *src TSRMLS_DC)') dnl {{{
     121EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_t *src, zend_class_entry **index_to_ce TSRMLS_DC)') dnl {{{
    122122{
    123123    xc_processor_t processor;
     
    133133    }
    134134    processor.entry_var_src = src;
     135    processor.index_to_ce = index_to_ce;
    135136
    136137#ifdef ZEND_ENGINE_2
  • trunk/processor/head.m4

    r1558 r1560  
    5656include(__dir__`/string-helper.m4')
    5757
    58 #include "processor/class-helper.h"
    5958include(__dir__`/class-helper.m4')
    6059
  • trunk/processor/processor.m4

    r1558 r1560  
    120120#endif
    121121DEF_STRUCT_P_FUNC(`zend_object', , `dnl {{{
    122     dnl handle ce
    123     dnl IFCALCSTORE(`
    124     dnl     pushdef(`SRC', `ifelse(`$1', `ce', `src->ce->name', `')')
    125     dnl     pushdef(`DST', `ifelse(`$1', `ce', `(*(char **)&dst->ce)', `')')
    126     dnl     PROC_STRING(`ce')
    127     dnl     popdef(`SRC')
    128     dnl     popdef(`DST')
    129     dnl ', `IFRESTORE(`
    130     dnl     if (!(DST(`ce') = xc_lookup_class((const char *) SRC(`ce') TSRMLS_CC))) {
    131     dnl         DST(`ce') = zend_standard_class_def;
    132     dnl         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s not found when restroing variable", (const char *) SRC(`ce'));
    133     dnl     }
    134     dnl     DONE(`ce')
    135     dnl ', `
    136     dnl     PROCESS(zend_ulong, ce)
    137     dnl ')')
    138122    IFCALC(`
    139123        xc_var_collect_class(processor, SRC(ce) TSRMLS_CC);
    140124        DONE(ce)
    141125    ', `IFSTORE(`
    142         DST(ce) = (zend_class_entry *) xc_var_ce_to_index(processor, DST(ce) TSRMLS_CC);
     126        DST(ce) = (zend_class_entry *) xc_var_store_ce(processor, DST(ce) TSRMLS_CC);
    143127        DONE(ce)
    144128    ', `IFRESTORE(`
    145         DST(ce) = xc_var_index_to_ec(processor, (size_t) DST(ce) TSRMLS_CC);
     129        assert(processor->index_to_ce);
     130        DST(ce) = processor->index_to_ce[(size_t) DST(ce)];
    146131        DONE(ce)
    147132    ', `
    148         PROCESS_SCALAR(ce, %lu, unsigned long)
     133        PROCESS_SCALAR(ce, lu, unsigned long)
    149134    ')')')
    150135
  • trunk/processor/var-helper-t.h

    r1558 r1560  
    88xc_vector_t           class_names;          /* in calc only */
    99HashTable             class_name_to_index;  /* in calc/store only */
     10zend_class_entry    **index_to_ce;     /* in restore only */
    1011/* }}} */
  • trunk/processor/var-helper.h

    r1559 r1560  
    4040
    4141    if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) {
    42         xc_constant_string_t class_name = { ce->name, ce->name_length };
     42        xc_constant_string_t class_name;
     43        class_name.str = (char *) ce->name;
     44        class_name.len = ce->name_length;
    4345        xc_vector_push_back(&processor->class_names, &class_name);
    4446    }
    4547}
    4648/* }}} */
    47 /* on store */
    48 static size_t xc_var_ce_to_index(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
     49static size_t xc_var_store_ce(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */
    4950{
    5051    size_t *index;
     
    5960/* }}} */
    6061/* on restore */
    61 static zend_class_entry *xc_var_index_to_ec(xc_processor_t *processor, size_t index TSRMLS_DC) /* {{{ */
    62 {
    63     xc_constant_string_t *name = &processor->entry_var_src->class_names[index];
    64     zend_class_entry *ce;
    65 
    66     if (!(ce = xc_lookup_class(name->str, name->len TSRMLS_CC))) {
    67         ce = zend_standard_class_def;
    68         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s not found when restroing variable", name->str);
    69     }
    70     return ce;
    71 }
    72 /* }}} */
  • trunk/processor/var-helper.m4

    r1558 r1560  
    22define(`xc_var_store_handle', `IFSTORE(``xc_var_store_handle'($@)',``xc_var_store_handle' can be use in store only')')
    33define(`xc_var_restore_handle', `IFRESTORE(``xc_var_restore_handle'($@)',``xc_var_restore_handle' can be use in restore only')')
     4
     5define(`xc_collect_class', `IFCALC(``xc_collect_class'($@)',``xc_collect_class' can be use in calc only')')
     6define(`xc_var_store_ce', `IFSTORE(``xc_var_store_ce'($@)',``xc_var_store_ce' can be use in store only')')
  • trunk/util/xc_vector.h

    r1558 r1560  
    4949
    5050#define xc_vector_destroy(vector) xc_vector_destroy_impl(vector TSRMLS_CC)
     51#define xc_vector_clear(vector) do { (vector)->size = 0; } while (0)
    5152
    5253#define xc_vector_size(vector) ((vector)->size)
  • trunk/xcache/xc_utils.c

    r1385 r1560  
    639639/* }}} */
    640640#endif
     641zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC) /* {{{ */
     642{
     643    xc_cest_t *cest;
     644#ifdef ZEND_ENGINE_2
     645    if (zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &cest TSRMLS_CC) != SUCCESS) {
     646        return NULL;
     647    }
     648#else
     649    if (zend_hash_find(EG(class_table), class_name, class_name_len, (void **) &cest) != SUCCESS) {
     650        return NULL;
     651    }
     652#endif
     653    return CestToCePtr(*cest);
     654}
     655/* }}} */
  • trunk/xcache/xc_utils.h

    r1321 r1560  
    5757int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int oplineno TSRMLS_DC);
    5858#endif
     59
     60zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC);
Note: See TracChangeset for help on using the changeset viewer.